Skip to content

Commit

Permalink
fix(controller): Global parameter is not getting updated (#6401)
Browse files Browse the repository at this point in the history
* fix(controller): Global parameter is not getting updated

Signed-off-by: Saravanan Balasubramanian <sarabala1979@gmail.com>
  • Loading branch information
sarabala1979 committed Jul 27, 2021
1 parent adc17ff commit 060b727
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3348,7 +3348,13 @@ func (woc *wfOperationCtx) mergedTemplateDefaultsInto(originalTmpl *wfv1.Templat
}

func (woc *wfOperationCtx) substituteGlobalVariables() error {
wfSpec, err := json.Marshal(woc.execWf.Spec)
execWfSpec := woc.execWf.Spec

// To Avoid the stale Global parameter value substitution to templates.
// Updated Global parameter values will be substituted in 'executetemplate' for templates.
execWfSpec.Templates = nil

wfSpec, err := json.Marshal(execWfSpec)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6760,6 +6760,9 @@ func TestSubstituteGlobalVariables(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, woc.execWf)
assert.Equal(t, "mutex1", woc.execWf.Spec.Synchronization.Mutex.Name)
tempStr, err := json.Marshal(woc.execWf.Spec.Templates)
assert.NoError(t, err)
assert.Contains(t, string(tempStr), "{{workflow.parameters.message}}")
}

var wfPending = `
Expand Down

0 comments on commit 060b727

Please sign in to comment.