-
Notifications
You must be signed in to change notification settings - Fork 904
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
feat: add workload-ref/generation to rollout #1198
Conversation
0e35cf2
to
34a6cb1
Compare
Codecov Report
@@ Coverage Diff @@
## master #1198 +/- ##
==========================================
+ Coverage 81.37% 81.38% +0.01%
==========================================
Files 106 106
Lines 9721 9776 +55
==========================================
+ Hits 7910 7956 +46
- Misses 1273 1279 +6
- Partials 538 541 +3
Continue to review full report at Codecov.
|
a0b9d1d
to
2ebd1ae
Compare
5ad3f4c
to
df74692
Compare
Kudos, SonarCloud Quality Gate passed!
|
Hi, @jessesuen , this PR is ready for review. (I was trying to increase the test coverage, but still fall short of the required target. Please provide any advice if you have. Thanks.) |
Thanks for working on this. Will be taking a look at this in the coming days. |
@alexmt thinks there might be a better way to address the issue. I will ask him to put an alternative proposal in the issue. |
Sounds good. Will follow up the thread. |
I checked in with @alexmt about this again. He gave it some more thought but didn't have a better proposal. So we will go with the original improvement as discussed in the issue. |
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.
Change looks very good. Some minor points
rollout/temlateref.go
Outdated
if key, err := cache.MetaNamespaceKeyFunc(ro); err == nil { | ||
r.rolloutWorkQueue.Add(key) | ||
} |
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.
There's actually no need to enqueue the rollout to r.rolloutWorkQueue
anymore with this new approach because the act of annotating the rollout automatically gets the rollout into the workqueue. I think we should remove these three lines because we may be operating on the rollout prematurely (where the annotation is not reflected in the rollout), which could cause ConflictErrors during reconciliation.
Can we remove these lines?
if key, err := cache.MetaNamespaceKeyFunc(ro); err == nil {
r.rolloutWorkQueue.Add(key)
}
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.
You are correct. Thanks for the explanation.
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 , I tested remove the above 3 lines. However, the unit test failed at
argo-rollouts/rollout/temlateref_test.go
Lines 366 to 367 in 460262e
require.False(t, done) | |
assert.Equal(t, "default/my-rollout", item) |
The Get()
does not return any object. I think this is because the test code uses argoprojectclientset := fake.Clientset{}
. Any advice?
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 think test needs to be modified since we no longer update workqueue directly. So I think this part of test can be removed as well.
Maybe in place of this, we verify the rollout was annotated.
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.
True. Will change the test to verify annotation is added.
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.
In fact, can we remove the rolloutWorkQueue
field entirely from NewInformerBasedWorkloadRefResolver?
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 , I updated the test to verifying the annotations are added for the rollout. However, it looks like the test clientset can't turn interface{}
to rollout. Could you help to test a look?
- Add a "rollout.argoproj.io/workload-generation" annotation to the rollout metadata, which equals to the generation of reference workload - workload-generation is updated when the referenced workload is updated. - status.workloadObservedGeneration records the observed generation of the rollout - workloadref e2e test is update Signed-off-by: Hui Kang <[email protected]>
- fix proto number after rebase Signed-off-by: Hui Kang <[email protected]>
8d7fcfd
to
9d51b8e
Compare
d3a5abf
to
bb5ad39
Compare
rollout/temlateref.go
Outdated
for _, ro := range rollouts { | ||
if key, err := cache.MetaNamespaceKeyFunc(ro); err == nil { | ||
r.rolloutWorkQueue.Add(key) | ||
un, ok := ro.(*unstructured.Unstructured) |
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.
@jessesuen , in the e2e test, the ro can be mappted to *unstructured.Unstructured
without any issue (so the e2e test passed). However, in the unit test code, the rollout can't be resolved. Do you have any idea about this? Thanks.
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.
FYI, to reproduce: go test -timeout 999s -run ^TestRequeueReferencedRollouts$ ./rollout -v
8bd3ab6
to
f2d24f4
Compare
f2d24f4
to
e7ceecc
Compare
…ange - doc update: migration.md - Remove the workqueue of informerBasedTemplateResolver Signed-off-by: Hui Kang <[email protected]>
e7ceecc
to
ab451dc
Compare
utils/rollout/rolloututil.go
Outdated
func isWorkloadGenerationObserved(ro *v1alpha1.Rollout) bool { | ||
if _, ok := annotations.GetWorkloadGenerationAnnotation(ro); !ok { | ||
return true | ||
} | ||
workloadGeneration, _ := annotations.GetWorkloadGenerationAnnotation(ro) | ||
observedWorkloadGen, err := strconv.Atoi(ro.Status.WorkloadObservedGeneration) | ||
if err != nil { | ||
return true | ||
} | ||
|
||
return int32(observedWorkloadGen) == workloadGeneration |
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.
-
The code scanner is catching a valid concern with the use of strconv.Atoi. We should use
strconv.ParseInt(ro.Status.WorkloadObservedGeneration, 10, 32)
instead -
I just noticed that we may not handle the case properly where we still may have a workloadGenerationAnnotation on the rollout (leftover from when it switched from workload to non-workload ref) even if rollout switched to using inline template.
I think this function needs to check if ro.Spec.WorkloadRef != nil
before proceeding. At the same time, I think we should remove the workload generation annotation from the rollout, since I don't think that gets cleaned up at the moment.
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 the feedback. The PR is updated and an e2e test case is added to verify the workload generation annotation is removed after it switches to inline template.
10e2d89
to
990c469
Compare
- e2e test added Signed-off-by: Hui Kang <[email protected]>
48149d5
to
adb1264
Compare
Signed-off-by: Hui Kang <[email protected]>
adb1264
to
d803ca0
Compare
Kudos, SonarCloud Quality Gate passed!
|
the rollout metadata, which equals to the generation of reference
workload
updated.
of the rollout
Signed-off-by: Hui Kang [email protected]
close #1189
Checklist:
"fix(controller): Updates such and such. Fixes #1234"
.