-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fixed issue with compat/client with applying empty structures to api server #454
Fixed issue with compat/client with applying empty structures to api server #454
Conversation
79bee55
to
490e791
Compare
…server - Added downconvert to cronjobs
490e791
to
25d6fdd
Compare
@jortel This should be a smaller scoped PR, only addressing the issue with resource
|
@@ -109,11 +122,9 @@ func (c Client) Get(ctx context.Context, key k8sclient.ObjectKey, in runtime.Obj | |||
if err != nil { | |||
return err | |||
} | |||
if in != 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.
The purpose for this check is so that we don't up-convert the result unless it was down-converted.
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 it is already being done in the scheme.Convert
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.
Drilling down in the code, it seems it's still doing some work we could/should avoid. Thoughts?
The check provides some symmetry in that we conditionally convert as needed both up and down.
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.
Agreed
pkg/compat/client.go
Outdated
@@ -151,6 +164,10 @@ func (c Client) Create(ctx context.Context, in runtime.Object) error { | |||
// The resource will be converted to a compatible version as needed. | |||
func (c Client) Delete(ctx context.Context, in runtime.Object, opt ...k8sclient.DeleteOptionFunc) error { | |||
obj := c.downConvert(in) | |||
err := scheme.Scheme.Convert(in, obj, ctx) |
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.
Seems like doing the down-conversion in the downConvert()
method would make more sense.
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.
👍
return c.Client.Update(ctx, obj) | ||
} | ||
|
||
func (c Client) Status() k8sclient.StatusWriter { |
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 thought this was needed to implement the Client
interface. No?
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.
It is inheriting that from the client inside the structure.
continue | ||
} | ||
unstructured.SetNestedField(r.Object, true, fields...) | ||
r.Spec.Suspend = pointer.BoolPtr(true) |
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.
👍 Using pointer.BoolPtr()
is so much cleaner than using a bool variable.
4015159
to
0cdf840
Compare
if c.Minor < 16 { | ||
switch obj.(type) { |
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.
Cast to Type
and switch statement is a nice improvement.
@Danil-Grigorev These changes look really good but no longer include a few changes I recall seeing in earlier versions of the PR. Mainly files related to generating the conversions. Earlier you added the conversion-gen to our Makefile but no longer see that diff. Also, IIRC you added a subpackage to our |
Look into PR #460, those two PRs are addressing different issues.
Yes, they are needed for @jortel Tested this in a full setup, everything works. |
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
Re-implementing functionality of #443