-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix: type-aware application of template defaults (#14899) #15144
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
Conversation
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
📝 WalkthroughWalkthroughThe changes address incorrect handling of HTTP templates in the controller. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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: 0
🧹 Nitpick comments (2)
workflow/controller/operator_tmpl_default_test.go (1)
273-289: LGTM! Test correctly validates the fix for issue #14899.This test case effectively verifies that container-specific template defaults are not incorrectly applied to HTTP templates. The assertions properly confirm:
- The template type remains HTTP after defaults are merged
- No Container field is populated (remains nil)
This directly addresses the root cause described in the issue where HTTP templates were being treated as container/Pod templates.
Optional enhancement: Consider adding a similar test for Plugin templates, as they were also mentioned in the PR objectives as potentially affected by this issue. However, this is not necessary for the current fix.
workflow/controller/operator.go (1)
4286-4327: The fix correctly addresses the template type filtering issue.The approach of using reflection to identify and zero out non-applicable template-type defaults is sound. The logic correctly:
- Identifies pointer-to-struct fields that represent template types
- Filters out defaults for types that don't match the target template
- Applies remaining defaults via strategic merge patch
- Preserves the original template type
The code relies on struct field names exactly matching
TemplateTypeenum values (e.g., fieldContainer→TemplateType("Container")). This coupling is correct and intentional—all Template struct fields (Container,ContainerSet,Script,HTTP,Plugin,DAG,Suspend,Data,Resource) have names that exactly match their corresponding enum values, and the reflection filter correctly selects only pointer-to-struct fields while skipping others like theStepsslice. A brief comment documenting this assumption would help future maintainers understand the implicit coupling between field names and enum values.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
pkg/apis/workflow/v1alpha1/workflow_types.go(1 hunks)workflow/controller/operator.go(1 hunks)workflow/controller/operator_tmpl_default_test.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
workflow/controller/operator_tmpl_default_test.go (3)
pkg/apis/workflow/v1alpha1/marshall.go (1)
MustUnmarshalWorkflow(71-75)test/e2e/fixtures/given.go (1)
NoError(244-247)pkg/apis/workflow/v1alpha1/workflow_types.go (1)
TemplateTypeHTTP(55-55)
⏰ 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). (8)
- GitHub Check: Build Binaries (cli)
- GitHub Check: Build Binaries (controller)
- GitHub Check: Codegen
- GitHub Check: Unit Tests
- GitHub Check: Lint
- GitHub Check: Windows Unit Tests
- GitHub Check: argo-images (argocli)
- GitHub Check: argo-images (argoexec)
🔇 Additional comments (2)
pkg/apis/workflow/v1alpha1/workflow_types.go (1)
60-75: LGTM! Clean validation method.The
IsValid()implementation correctly validates all known template types and follows the existing pattern established byPodGCStrategy.IsValid()in this file. All 10 valid template types are properly included, and the method appropriately returns false for unknown types.workflow/controller/operator_tmpl_default_test.go (1)
115-127: LGTM! Well-structured test fixture.The
httpWfconstant provides a clean, minimal HTTP workflow fixture for testing template defaults behavior with HTTP templates. The YAML structure is valid and consistent with other test constants in this file.
Joibel
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.
Thanks for contributing this
|
Caution Docstrings generation - FAILED No docstrings were generated. |
6234b14 to
f8bbfb0
Compare
…oproj#14899) Signed-off-by: Fredrik Karlström <[email protected]>
Signed-off-by: Fredrik Karlström <[email protected]>
f8bbfb0 to
bc26adb
Compare
|
❌ Cherry-pick failed for 3.6. Please check the workflow logs for details. |
Signed-off-by: Fredrik Karlström <[email protected]>
|
🍒 Cherry-pick PR created for 3.7: #15173 |
Signed-off-by: Fredrik Karlström <[email protected]> Signed-off-by: Alan Clucas <[email protected]>
(cherry picked from commit c8b66b2) Signed-off-by: Fredrik Karlström <[email protected]> Signed-off-by: Alan Clucas <[email protected]>
…#15144 for 3.7) (#15173) Signed-off-by: Fredrik Karlström <[email protected]> Signed-off-by: Alan Clucas <[email protected]> Co-authored-by: Lars F. Karlström <[email protected]>
(cherry picked from commit c8b66b2) Signed-off-by: Fredrik Karlström <[email protected]> Signed-off-by: Alan Clucas <[email protected]>
Fixes #14899
Motivation
As illustrated in the referenced issue as well as via the example in the verification section,
templateDefaultswithcontainerproperties cause templates of other types (http, plugin) to fail outright.Making use of
templateDefaultsshould not prevent us from also using HTTP or Plugin templates, and vice-versa.The issue can be remedied by ensuring that only relevant Template-type default values are applied while merging.
Modifications
IsValid() boolmethod forTemplateType, similar to what already exists for e.g.PodGCStrategymergedTemplateDefaultsIntoto only apply Template-type defaults for matching template typesHTTPTemplateis unaffected byContainerdefault valuesVerification
Successfully executed the following example workflow in a local (devcontainer) environment:
Documentation
n/a
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.