-
Notifications
You must be signed in to change notification settings - Fork 3.5k
fix: use input.defaults for suspend templates #15240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use input.defaults for suspend templates #15240
Conversation
…spend templates When a suspend node times out, the output parameters need a default value (valueFrom.default) to be used. Previously, users had to manually specify the default in the output's valueFrom even when they had already defined a default on the matching input parameter. This fix automatically populates the output parameter's valueFrom.default from the matching input parameter's default when: - The output parameter has valueFrom.supplied set - The output doesn't already have a valueFrom.default - There's an input parameter with the same name that has a default This allows suspend templates with input parameters that have defaults and matching output parameters with valueFrom.supplied to work correctly when the suspend duration times out, without requiring users to duplicate the default value in the output specification. Signed-off-by: Alan Clucas <[email protected]>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughThe changes add a fallback mechanism to suspend node handling in the workflow operator. When an output parameter lacks an explicit default but was supplied, the operator now searches the corresponding input parameters for a matching name with a default value and uses that. This enables suspend nodes to inherit defaults from their inputs when no specific output default is provided. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In @workflow/controller/operator_test.go:
- Around line 2999-3049: In suspendWithInputDefaultsTemplate update the select
parameter default to be quoted (change default: default to default: "default")
to keep scalar style consistent, and clarify the suspend.duration: "0s" behavior
by either adding a brief inline comment in the template next to suspend.duration
explaining it triggers immediate auto-resume or renaming the test
(suspend-with-input-defaults) to indicate it tests auto-resume/timeout behavior;
target the suspendWithInputDefaultsTemplate string and the select
parameter/default and suspend.duration entries when making the change.
🧹 Nitpick comments (1)
workflow/controller/operator.go (1)
3855-3866: Consider using DeepCopy for defensive pointer handling.The logic correctly addresses the issue where suspend node outputs should inherit input defaults. However, the direct pointer assignment
param.ValueFrom.Default = inParam.Defaultcauses both the input and output parameters to share the same underlying*AnyStringobject.While this is likely safe in practice (defaults are typically not mutated after initialization), using a deep copy would be more defensive and prevent potential unintended side effects if either value were ever modified elsewhere.
🛠️ Suggested defensive copy
if param.ValueFrom.Default == nil { for _, inParam := range tmpl.Inputs.Parameters { if inParam.Name == param.Name && inParam.Default != nil { - param.ValueFrom.Default = inParam.Default + param.ValueFrom.Default = inParam.Default.DeepCopy() break } } }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
workflow/controller/operator.goworkflow/controller/operator_test.go
🧰 Additional context used
🧬 Code graph analysis (2)
workflow/controller/operator_test.go (2)
pkg/apis/workflow/v1alpha1/workflow_types.go (2)
Outputs(1623-1639)Parameter(1000-1025)pkg/apis/workflow/v1alpha1/marshall.go (1)
MustUnmarshalWorkflow(71-75)
workflow/controller/operator.go (2)
pkg/apis/workflow/v1alpha1/workflow_types.go (2)
ValueFrom(1028-1056)Inputs(975-987)workflow/common/params.go (1)
Parameters(6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Lint
- GitHub Check: Build Binaries (cli)
- GitHub Check: Build Binaries (controller)
- GitHub Check: Windows Unit Tests
- GitHub Check: Unit Tests
- GitHub Check: argo-images (argocli)
- GitHub Check: argo-images (argoexec)
Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
fd83f40 to
02df8a5
Compare
|
This PR fixes the output issue but it doesn't address the UI issue mentioned in #12896 . I did take a look at the UI code, and I believe the issue is here: In - if (paramClone.enum) {
- paramClone.value = paramClone.default;
- }
+ if (paramClone.enum && !paramClone.value) {
+ paramClone.value = paramClone.default;
+ }Currently, it overwrites |
I'd prefer to fix the UI issue separately as it's not the same bug. I've removed the "Fixes #12896" from the desctiption. |
eduardodbr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can submit a fix to the UI then, since I already looked into it
Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
Signed-off-by: Alan Clucas <[email protected]>
|
🍒 Cherry-pick PR created for 4.0: #15482 |
|
🍒 Cherry-pick PR created for 3.7: #15483 |
|
🍒 Cherry-pick PR created for 3.6: #15484 |
Motivation
This workflow apparently worked in 3.4, I haven't tried to work out why.
Modifications
We now observe the default values of the inputs if the output doesn't have defaults, for suspend templates only
Verification
New unit test, which verified the workflow passes and checks the values.
The workflow would formerly failed.
Documentation
None required, bug fix
Summary by CodeRabbit
Release Notes
✏️ Tip: You can customize this high-level summary in your review settings.