Skip to content

fix(controller): check storedTemplates in GetNodeTemplate before live CWT lookup - #15661

Closed
nancysangani wants to merge 1 commit into
argoproj:mainfrom
nancysangani:fix/15655-get-node-template-stored-templates
Closed

fix(controller): check storedTemplates in GetNodeTemplate before live CWT lookup#15661
nancysangani wants to merge 1 commit into
argoproj:mainfrom
nancysangani:fix/15655-get-node-template-stored-templates

Conversation

@nancysangani

Copy link
Copy Markdown
Contributor

Fixes #15655

When a cross-CWT templateRef node's template is removed from the CWT
after the pod is already running, assessNodeStatus was spuriously marking
the node Error with "template not found" — even though the pod completed
successfully.

The fix makes GetNodeTemplate check wf.Status.StoredTemplates first
(mirroring what resolveTemplateImpl already does during execution) before
falling back to the live CWT informer cache. The fallback is kept for
edge cases like controller restarts.

Added a unit test that reproduces the bug by leaving the live CWT cache
empty while the template exists in storedTemplates.

Copilot AI review requested due to automatic review settings March 4, 2026 15:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a controller bug where assessNodeStatus could incorrectly mark templateRef nodes as Error (“template not found”) when the referenced ClusterWorkflowTemplate was changed after pod creation, by preferring wf.Status.StoredTemplates over the live CWT informer cache during node template lookup.

Changes:

  • Update wfOperationCtx.GetNodeTemplate to check wf.Status.StoredTemplates before falling back to a live CWT lookup for templateRef nodes.
  • Add a unit test that reproduces the bug scenario by ensuring the live CWT cache is empty while the template exists in StoredTemplates.
  • Update quick-start docs to use server-side apply for the minimal install manifest.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
workflow/controller/operator.go Changes GetNodeTemplate to prefer StoredTemplates for templateRef nodes, avoiding spurious “template not found” errors after live CWT edits.
workflow/controller/operator_test.go Adds regression coverage ensuring stored templates are used even when live CWT informer cache doesn’t have the referenced template.
docs/quick-start.md Switches the quick-start install command to kubectl apply --server-side.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/quick-start.md
Comment thread workflow/controller/operator_test.go Outdated
Comment on lines +1946 to +1959
const storedKey = "cluster/cwt-helper/say-hello"

wf := &wfv1.Workflow{
ObjectMeta: metav1.ObjectMeta{
Name: "cwt-templateref-bug-test",
Namespace: "default",
},
Spec: wfv1.WorkflowSpec{
Entrypoint: "main",
},
Status: wfv1.WorkflowStatus{
StoredTemplates: map[string]wfv1.Template{
storedKey: storedTmpl,
},

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test hard-codes the storedTemplates map key ("cluster/cwt-helper/say-hello"), which couples the test to the internal key format used by resolveTemplateReference. To make the test resilient to future key format changes, populate StoredTemplates via wf.SetStoredTemplate(...) (using the node as the TemplateReferenceHolder) instead of constructing the map entry by hand.

Copilot uses AI. Check for mistakes.
@nancysangani

Copy link
Copy Markdown
Contributor Author

/cc @Joibel
/cc @thevilledev

@thevilledev thevilledev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor test related comment.

Comment thread workflow/controller/operator_test.go Outdated
… CWT lookup

Signed-off-by: Nancy <9d.24.nancy.sangani@gmail.com>
@nancysangani
nancysangani force-pushed the fix/15655-get-node-template-stored-templates branch from eeeaa9f to 90ff6d7 Compare March 15, 2026 19:03
@nancysangani

Copy link
Copy Markdown
Contributor Author

@thevilledev Please review it when you get a chance, I have implemented the suggested changes. Thanks!

@thevilledev thevilledev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM. Pending for maintainer feedback

@deynekas

deynekas commented Jun 23, 2026

Copy link
Copy Markdown

What is the status of this please?
In our case we experienced following behaviour caused by same issue:

  1. Multiple workflows were running, executing steps that reference ClusterWorkflowTemplate/workflow-v1
  2. We deployed an update to the CWT workflow-v1 that added a new output parameter: jenkinsBuildNumber
  3. Workflows submitted BEFORE the change hung indefinitely even though workflow-v1 completed successfully

From my POV This bug fundamentally breaks the immutability guarantee that storedTemplates was designed to provide. Template changes should NOT affect in-flight workflows, but currently they do because:

  • Execution path: Correctly uses storedTemplates (immutable)
  • Assessment path: Queries live CWT (mutable) ← This PR fixes this

/cc @Joibel
/cc @thevilledev

@Joibel
Joibel requested a review from a team as a code owner July 7, 2026 15:55
@Kolajik

Kolajik commented Aug 25, 2026

Copy link
Copy Markdown

👋 Hello, any update on this issue?

We're experiencing the same issue @deynekas reported. It would help us tremendously with making changes to any WorkflowTemplate such that it doesn't affect running workflows. Thanks!

@Joibel

Joibel commented Aug 25, 2026

Copy link
Copy Markdown
Member

#15659 is the same fix, but with better tests. Closing this, preferring that one.

@Joibel Joibel closed this Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cross-CWT templateRef node spuriously marked Error when CWT is modified after pod creation

6 participants