-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
🐛 Fix informer cache creating pointers to pointers #796
🐛 Fix informer cache creating pointers to pointers #796
Conversation
Spec string `json:"spec,omitempty"` | ||
} | ||
|
||
// DeepCopyObject implements runtime.Object |
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 handwrote these mostly because I was too lazy to figure out how to plug deepcopy-gen into a hackscript and have it verified by CI. Also it may not be able to cope with a folder that contains multiple packages (controller
and controller_test
). Since the correctness of the DeepCopies is not really relevant for the test, thats IMHO good enough
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 you add a comment with the above? :)
Awesome job on the test @alvaroaleman! I got about 50% of the way there when I attempted it last year but had brought a lot more code along so this looks much cleaner than my test implementation. 😄 |
Yeah it actually turned out to be a lot more involved than anticipated, initially I thought I could directly test the |
@vincepri Mind having a look? |
Spec string `json:"spec,omitempty"` | ||
} | ||
|
||
// DeepCopyObject implements runtime.Object |
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 you add a comment with the above? :)
@@ -93,7 +93,11 @@ func (ip *informerCache) List(ctx context.Context, out runtime.Object, opts ...c | |||
} | |||
// http://knowyourmeme.com/memes/this-is-fine | |||
elemType := reflect.Indirect(reflect.ValueOf(itemsPtr)).Type().Elem() |
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.
For posterity, can we also add a comment here explaining what we're trying to do and why? I checked out the code and understood we're pretty much trying to figure out the type of the list passed in, but that might be a lot to ask for folks not familiar with the codebase.
Let's also move the logic to a local function and add some unit tests for it.
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. I had to move the UnconventionalListType
into a different package, because its now used by both unit and integration tests and would otherwise have caused an import cycle.
/assign |
aa7cb59
to
c35cff4
Compare
When the list type is already a pointer this code results in a cache type of **Type which can't be cast to runtime.Object. This adds a check to the function to only grab a pointer to a type if it is not already a ptr type.
c35cff4
to
e66416c
Compare
e66416c
to
bd6a4b5
Compare
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
/assign @DirectXMan12 @gerred
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, DirectXMan12 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 |
Makes the cache cope with list types that have a slice of pointers as
Items
field.Fixes #656
Supersedes and thereby closes #667