-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
patch
service status instead of update
in service controller
#77984
Conversation
code looks good /lgtm |
Humm, need to fix the unit test:
|
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestPatch(t *testing.T) { |
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.
Should we have a test case where we attempt a separate update before the merge patch?
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.
Yeah would be great to verify that. Added now.
ea5618b
to
2af970d
Compare
Did a minimal fix for now. I'm planing to cleanup the test when we remove the cache layer with finalizer support. |
2af970d
to
e3df6fe
Compare
@@ -404,6 +417,10 @@ func TestProcessServiceUpdate(t *testing.T) { | |||
|
|||
for _, tc := range testCases { | |||
newSvc := tc.updateFn(tc.svc) | |||
if _, err := client.CoreV1().Services(tc.svc.Namespace).Create(tc.svc); err != nil { | |||
t.Errorf("Failed to prepare service %s for testing: %v", tc.key, err) | |||
continue |
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.
t.Fatalf
and get rid of continue
?
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.
Yep, fixed now.
|
||
func TestPatch(t *testing.T) { | ||
svcOrigin := &v1.Service{ | ||
ObjectMeta: metav1.ObjectMeta{ |
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.
Should at least start with a name?
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.
Added a name.
} | ||
klog.V(2).Infof("Successfully patch status for service %s", 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.
I'd say that 2 is too verbose for this thoughts?
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, given that we don't even log this before. Bumped it to 4.
59561d1
to
45cf9d5
Compare
} | ||
klog.V(4).Infof("Successfully patch status for service %s", 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.
nit: Successfully patched
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.
Oops, fixed now. Thanks for the quick review!
/approve |
45cf9d5
to
7fdd270
Compare
/assign @liggitt |
pkg/controller/service/util/util.go
Outdated
limitations under the License. | ||
*/ | ||
|
||
package util |
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.
One more nit (more of a personal preference): I don't think a util
package is necessary for patch, can just have a patch.go
go file in pkg/controller/service/
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.
Agree. Fewer public methods to accumulate callers, the better
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, good point. Put it into patch.go
instead.
Rbac change looks good, let me know when the rest is reviewed |
7fdd270
to
6a86244
Compare
pkg/controller/service/patch.go
Outdated
) | ||
|
||
// patch patches service given the origin and updated ones. | ||
// Caller is free to decide what (e.g. metadata, spec or status) is |
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.
Is this comment accurate?
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.
Not anymore. This patch should only update status (for LB IP) and metadata (for finalizer) in service controller's use case. Let me update that.
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. PTAL
Co-authored-by: Josh Horwitz <horwitzja@gmail.com>
Co-authored-by: Josh Horwitz <horwitzja@gmail.com>
Co-authored-by: Josh Horwitz <horwitzja@gmail.com>
6a86244
to
cda73eb
Compare
/lgtm |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewsykim, liggitt, 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 |
/retest |
/test pull-kubernetes-e2e-gce-100-performance |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Split from #54569. This PR updates service controller to use patch when updating service's status. As #38349 (comment) mentioned, this will help with the conflicting update situation.
Which issue(s) this PR fixes:
Fixes #38349
Special notes for your reviewer:
/cc @bowei @andrewsykim @jhorwit2 @liggitt
Does this PR introduce a user-facing change?: