-
Notifications
You must be signed in to change notification settings - Fork 880
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: workload rollout spec is invalid template is not empty #1224
Conversation
@jessesuen , after some investigation, I found that argo-rollouts/rollout/controller.go Line 462 in ff65b39
The check could be placed during resolving the workload ref for the first time. Is there any corner case the fix does not cover? |
Codecov Report
@@ Coverage Diff @@
## master #1224 +/- ##
=======================================
Coverage 81.29% 81.30%
=======================================
Files 106 106
Lines 9522 9527 +5
=======================================
+ Hits 7741 7746 +5
Misses 1256 1256
Partials 525 525
Continue to review full report at Codecov.
|
0eb921f
to
67ce1b0
Compare
@huikang - the original problem was that it was possible for a user to make a mistake in the spec (using my example) without that error surfacing into a condition (there was no update to status). And so the user did not know why the rollout was stuck. Will this fix solve that? |
I am not sure if I understand your question. With the PR, if the uses submits a rollout like your example, the get rollout will show the following error
Since the change occurs to To prevent the user makes a mistake, do you mean change is suppose to throw an error when user submit the manifest (or even using |
// When workloadRef is resolved for the first time, TemplateResolvedFromRef = false. | ||
// In this case, template must not be set | ||
if !rollout.Spec.TemplateResolvedFromRef && !rollout.Spec.EmptyTemplate() { | ||
return fmt.Errorf("template must be empty for workload reference rollout") | ||
} | ||
|
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.
Instead of in here, can we put this in validation library so that the linter can catch the problem?
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.
Updated. The method is moved to validation package. However, lint still can not catch the problem as it reports the following error.
Error: spec.template.spec.containers: Required value
Please see the test case I added to validation_test.go
. During reconciliation time, since the template.spec.containers
is filled by clientset.Get(), validation method will only report this error -template must be empty for workload reference rollout
.
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.
Hi, @jessesuen , the validation are placed in both Resolve and ValidateRolloutSpec method. In ValidateRolloutSpec
, an additional condition (!rollout.Spec.TemplateResolvedFromRef
) is added because during reconciliation template is filled prior to validation; otherwise it results in false alarm.
An e2e test is added.
Yes, this answers my question! With the original problem, the rollout |
4caf48b
to
5a1551f
Compare
- Check lables and annotations of the template for workloadRef - Add e2e test Signed-off-by: Hui Kang <[email protected]>
d9d1962
to
e8e4493
Compare
Signed-off-by: Hui Kang <[email protected]>
e8e4493
to
5427383
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
…#1224) Signed-off-by: Hui Kang <[email protected]> Signed-off-by: caoyang001 <[email protected]>
Signed-off-by: Hui Kang [email protected]
close #1222
Checklist:
"fix(controller): Updates such and such. Fixes #1234"
.