-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
Let the service controller retry when presistUpdate returns a conflict error #68087
Conversation
/ok-to-test |
@grayluck Can you update the release note to explain what this fixes? Thanks. |
where is the test? |
/sig apps |
/hold |
Unit test added. |
/retest |
33fd9e6
to
482a499
Compare
Might need to run |
Done. Thanks! |
Release note updated. |
/milestone v1.12 |
@grayluck: You must be a member of the kubernetes/kubernetes-milestone-maintainers github team to set the milestone. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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! Looks good, minor comments in test.
|
||
svcCache := controller.cache.getOrCreate(svcName) | ||
if err := controller.processServiceUpdate(svcCache, svc, svcName); err == nil { | ||
t.Errorf("controller.processServiceUpdate() = nil, want error") |
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.
Fatalf here? We won't get event below anyway if this doesn't error out.
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.
Done.
retryMsg := "Error creating load balancer (will retry)" | ||
if gotEvent := func() bool { | ||
events := controller.eventRecorder.(*record.FakeRecorder).Events | ||
for len(events) > 0 { |
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.
Can we do something similar to
kubernetes/pkg/cloudprovider/providers/gce/gce_loadbalancer_utils_test.go
Lines 385 to 403 in 6ecec23
func checkEvent(t *testing.T, recorder *record.FakeRecorder, expected string, shouldMatch bool) bool { | |
select { | |
case received := <-recorder.Events: | |
if strings.HasPrefix(received, expected) != shouldMatch { | |
t.Errorf(received) | |
if shouldMatch { | |
t.Errorf("Should receive message \"%v\" but got \"%v\".", expected, received) | |
} else { | |
t.Errorf("Unexpected event \"%v\".", received) | |
} | |
} | |
return false | |
case <-time.After(2 * time.Second): | |
if shouldMatch { | |
t.Errorf("Should receive message \"%v\" but got timed out.", expected) | |
} | |
return true | |
} | |
} |
Seems better to have an timeout on this.
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.
Everything is synchronous in this test. The time processServiceUpdate is returned, all events should be recorded. And "for len(events) > 0" guards that we will not wait for future (and there won't be future events) here.
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.
Makes sense, thanks!
Thanks for the review, MrHohn! Commit updated. |
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.
/lgtm
retryMsg := "Error creating load balancer (will retry)" | ||
if gotEvent := func() bool { | ||
events := controller.eventRecorder.(*record.FakeRecorder).Events | ||
for len(events) > 0 { |
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.
Makes sense, thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: grayluck, MrHohn The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/milestone v1.12 |
Thanks Bowei! |
/priority critical-urgent |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here: https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md. |
…87-upstream-release-1.11 Automated cherry pick of #68087
What this PR does / why we need it:
If a load balancer is changed while provisioning, it will fall into an error state and will not self-recover.
This PR picks up the conflict error and let serviceController retry in order to get the load balancer out of error state.
Special notes for your reviewer:
/assign @MrHohn @rramkumar1
Release note: