feat: update argo to 2.12.4 (WIP)

This commit is contained in:
Andrey Melnikov
2021-01-12 15:58:49 -08:00
parent 8799a79643
commit 5a66c278e4
6 changed files with 449 additions and 230 deletions

View File

@@ -8,6 +8,8 @@ import (
"errors"
"fmt"
sq "github.com/Masterminds/squirrel"
"github.com/argoproj/argo/persist/sqldb"
"github.com/argoproj/argo/workflow/hydrator"
"github.com/google/uuid"
"github.com/onepanelio/core/pkg/util/gcs"
"github.com/onepanelio/core/pkg/util/label"
@@ -442,7 +444,7 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
for _, param := range opts.Parameters {
newParams = append(newParams, wfv1.Parameter{
Name: param.Name,
Value: param.Value,
Value: wfv1.AnyStringPtr(*param.Value),
})
passedParams[param.Name] = true
}
@@ -467,7 +469,7 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
for i := range wf.Spec.Arguments.Parameters {
param := wf.Spec.Arguments.Parameters[i]
if param.Name == "sys-name" {
uid, err := GenerateWorkspaceUID(*param.Value)
uid, err := GenerateWorkspaceUID(param.Value.String())
if err != nil {
return nil, err
}
@@ -482,7 +484,7 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
if reErr != nil {
return nil, reErr
}
value := re.ReplaceAllString(*param.Value, namespace)
value := re.ReplaceAllString(param.Value.String(), namespace)
if workspaceUID != "" {
reWorkspaceUID, reErr := regexp.Compile(`{{\s*workspace.uid\s*}}`)
@@ -491,8 +493,7 @@ func (c *Client) createWorkflow(namespace string, workflowTemplateID uint64, wor
}
value = reWorkspaceUID.ReplaceAllString(value, workspaceUID)
}
param.Value = &value
param.Value = wfv1.AnyStringPtr(value)
}
newParameters = append(newParameters, param)
@@ -659,7 +660,10 @@ func (c *Client) injectAccessForSidecars(namespace string, wf *wfv1.Workflow) ([
virtualServiceNameUUID := "vs-" + uuid.New().String()
hosts := []string{serviceName}
wf.Spec.Templates[tIdx].Outputs.Parameters = append(wf.Spec.Templates[tIdx].Outputs.Parameters,
wfv1.Parameter{Name: "sys-sidecar-url--" + s.Name, Value: &serviceName},
wfv1.Parameter{
Name: "sys-sidecar-url--" + s.Name,
Value: wfv1.AnyStringPtr(serviceName),
},
)
virtualService := map[string]interface{}{
"apiVersion": "networking.istio.io/v1alpha3",
@@ -813,11 +817,12 @@ func (c *Client) ValidateWorkflowExecution(namespace string, manifest []byte) (e
}
wftmplGetter := templateresolution.WrapWorkflowTemplateInterface(c.ArgoprojV1alpha1().WorkflowTemplates(namespace))
clusterWftmplGetter := templateresolution.WrapClusterWorkflowTemplateInterface(c.ArgoprojV1alpha1().ClusterWorkflowTemplates())
for _, wf := range workflows {
if err = c.injectAutomatedFields(namespace, &wf, &WorkflowExecutionOptions{}); err != nil {
return err
}
_, err = validate.ValidateWorkflow(wftmplGetter, &wf, validate.ValidateOpts{})
_, err = validate.ValidateWorkflow(wftmplGetter, clusterWftmplGetter, &wf, validate.ValidateOpts{})
if err != nil {
return
}
@@ -1547,7 +1552,9 @@ func (c *Client) RetryWorkflowExecution(namespace, uid string) (workflow *Workfl
return
}
wf, err = argoutil.RetryWorkflow(c, c.ArgoprojV1alpha1().Workflows(namespace), wf)
hy := hydrator.New(sqldb.ExplosiveOffloadNodeStatusRepo)
wf, err = argoutil.RetryWorkflow(c, hy, c.ArgoprojV1alpha1().Workflows(namespace), uid, true, "")
workflow = typeWorkflow(wf)
@@ -1565,7 +1572,7 @@ func (c *Client) ResubmitWorkflowExecution(namespace, uid string) (workflow *Wor
return
}
wf, err = argoutil.SubmitWorkflow(c.ArgoprojV1alpha1().Workflows(namespace), c, namespace, wf, &argoutil.SubmitOpts{})
wf, err = argoutil.SubmitWorkflow(c.ArgoprojV1alpha1().Workflows(namespace), c, namespace, wf, &wfv1.SubmitOpts{})
if err != nil {
return
}
@@ -1576,7 +1583,8 @@ func (c *Client) ResubmitWorkflowExecution(namespace, uid string) (workflow *Wor
}
func (c *Client) ResumeWorkflowExecution(namespace, uid string) (workflow *WorkflowExecution, err error) {
err = argoutil.ResumeWorkflow(c.ArgoprojV1alpha1().Workflows(namespace), uid, "")
hy := hydrator.New(sqldb.ExplosiveOffloadNodeStatusRepo)
err = argoutil.ResumeWorkflow(c.ArgoprojV1alpha1().Workflows(namespace), hy, uid, "")
if err != nil {
return
}
@@ -1610,7 +1618,8 @@ func (c *Client) TerminateWorkflowExecution(namespace, uid string) (err error) {
return err
}
err = argoutil.StopWorkflow(c.ArgoprojV1alpha1().Workflows(namespace), uid, "", "")
hy := hydrator.New(sqldb.ExplosiveOffloadNodeStatusRepo)
err = argoutil.StopWorkflow(c.ArgoprojV1alpha1().Workflows(namespace), hy, uid, "", "")
return
}