-
Notifications
You must be signed in to change notification settings - Fork 1.2k
client: update status subresource support #96
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
client: update status subresource support #96
Conversation
cc @grantr |
Seems fine to me. I'm curious what the plan is for other subresources. Intuitively, it seems fine to have a top-level |
I think its important to capture resource behaviors in the interface. CRDs have only two subresources at the moment, 'Status' and 'Scale'. Core resources have bind/exec/logs, so doesn't look like a whole lot. |
Yeah, that's what I was struggling with. The dynamic scale client isn't terribly complicated (compared to the typed clients), so we may just want to consider providing an easy handle to it, or wrapping it lightly (I'd advise against re-implementing it here -- it'd be a decent amount of copied logic). The current invocation looks like I'm also wary of having too many methods under the same "namespace" (interface), lest it get a bit confusing. We might want consider something like |
7397811
to
927acf2
Compare
Why do we need to provide
Same question why So going by the proposal above, Status subresource methods will look like:
Implementation in current PR looks like:
Implementation in the PR looks very intuitive because |
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.
Code looks good.
Personally would prefer .Status().Update(ctx, object)
(gives us a bit more flexibility in the future, IMO).
pkg/client/fake/client.go
Outdated
@@ -123,6 +123,11 @@ func (c *fakeClient) Update(ctx context.Context, obj runtime.Object) error { | |||
return c.tracker.Update(gvr, obj, accessor.GetNamespace()) | |||
} | |||
|
|||
func (c *fakeClient) UpdateStatus(ctx context.Context, obj runtime.Object) error { | |||
// TODO(droot): implement for *real* |
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.
we should prob implement this before merging.
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 am calling c.Update
now which will update the Status, but will also update the Spec part, which is wrong.
Still looking for a way to do it with underneath tracker.
927acf2
to
9d34003
Compare
pkg/client/fake/client.go
Outdated
func (c *fakeClient) UpdateStatus(ctx context.Context, obj runtime.Object) error { | ||
// TODO(droot): This results in full update of the obj (spec + status). Need | ||
// a way to update status field only. | ||
return c.Update(ctx, obj) |
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.
Couldn't figure out how to implement UpdateStatus behavior with tracker object.
@mengqiy any ideas ?
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 don't see an easier way except implementing it upstream.
It seems no one uses fakeclient's UpdateStatus, I think this is OK to be a starting point.
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.
Sounds good.
@DirectXMan12 added partial implementation of the UpdateStatus, should be ok for now. (fixing it completely will require re-doing the fake implementation)
Keeping flexibility aside for a moment, do you find |
c547d2c
to
25d0dce
Compare
@DirectXMan12 revised the interface/implementation as per our last conversation. PTAL. |
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.
minor test-related nit inline, otherwise good
return err | ||
} | ||
// TODO(droot): examine the returned error and check if it error needs to be | ||
// wrapped to improve the UX ? |
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.
we could always check discovery to see if the /status
subresource appeared in discovery first, if we really wanted to...
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 tip. Not critical for now, so not addressing this in this PR.
pkg/client/client_test.go
Outdated
close(done) | ||
}) | ||
|
||
It("should fail if the object does not pass server-side validation", func() { |
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 don't think we need to explicitly test server-side behavior. The implication is that we're using the status subresource 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.
+1, removed it.
25d0dce
to
3dbc006
Compare
@DirectXMan12 addressed the comments. PTAL. |
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've still got a couple of empty tests, otherwise looks good.
pkg/client/client_test.go
Outdated
close(done) | ||
}) | ||
|
||
It("should fail if the GVK cannot be mapped to a Resource", func() { |
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've still got a couple empty tests 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.
I wanted to have these placeholders as TODOs so that it can act as good-first-issues for new contributors.
Lets wait for today, I might be able to add these later today.
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.
Please mark them as pending then -- http://onsi.github.io/ginkgo/#pending-specs (if you're not going to add them now)
3dbc006
to
ad4fd79
Compare
@DirectXMan12 converted all TODO tests to pending specs (Thanks for the tip). PTAL whenever you get a chance. |
/lgtm Let's try and fill in those existing gaps in the tests in a follow-up PR shortly |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DirectXMan12, droot 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 |
…-subresource client: update status subresource support
Sending this (WIP) PR for an early feedback on the interface before I add tests.