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 authored Jul 23, 2021
1 parent c4bdc21 commit 4da8fd9
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 @@ -3378,7 +3378,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 @@ -6894,6 +6894,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 4da8fd9

Please sign in to comment.