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
Vendor k/*@v0.20 and controller-runtime@v0.8 #3651
Conversation
// TODO: Inefficient conversion - can we improve it? | ||
if err := s.Convert(*in, *out, 0); err != nil { |
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.
Due to this, I had to introduce https://github.com/gardener/gardener/pull/3651/files#diff-c7b64578d2ac95623dfd44edeb4a58700b755fa9bda6b8267965ec156363a6e6R76-R83. I'm not sure why the generation does not find the functions here:
gardener/pkg/apis/core/v1beta1/zz_generated.conversion.go
Lines 4366 to 4369 in 6f6cf8a
// Convert_v1beta1_SeedTemplate_To_core_SeedTemplate is an autogenerated conversion function. | |
func Convert_v1beta1_SeedTemplate_To_core_SeedTemplate(in *SeedTemplate, out *core.SeedTemplate, s conversion.Scope) error { | |
return autoConvert_v1beta1_SeedTemplate_To_core_SeedTemplate(in, out, s) | |
} |
I played with --extra-peer-dirs
but without success. Any pointers are appreciated.
/cc @stoyanr @ialidzhikov
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 also ran into a similar problem with k8s 1.20.
It looks like a regression in the code generator for k8s 1.20: kubernetes/kubernetes#98380
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 @schrodit for pointing this out. Then I guess the workaround I applied is fine for now until a fix was released, right?
Yes. I guess we will be able to get rid of the replace for |
OK, thanks @ialidzhikov. Also, @timuthy mentioned that we now should be able to get rid of https://github.com/gardener/gardener/tree/master/third_party/forked/kubernetes, so I will look into that. |
@rfranzke The pull request was assigned to you under |
@rfranzke Label priority/normal does not exist. |
664f0e6
to
0ae1899
Compare
OK, thanks to @ialidzhikov and @timuthy I've updated the PR now (and also use the latest, just released |
/assign |
|
||
c.EXPECT().Patch(ctx, worker, client.MergeFrom(workerWithAnnotation)) | ||
ctx := context.TODO() | ||
test.EXPECTPatch(ctx, c, expectedWorker, workerWithAnnotation) |
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.
Hmm, this is odd. I really liked the way it was before this PR (without any helper func for expecting patch)
c.EXPECT().Patch(ctx, worker, client.MergeFrom(workerWithAnnotation))
I see that the old way fails with error like:
Unexpected call to *client.MockClient.Patch([context.TODO 0xc00025ad80 0xc000899da0]) at /go/src/github.com/gardener/gardener/extensions/pkg/controller/utils.go:193 because:
expected call at /go/src/github.com/gardener/gardener/extensions/pkg/controller/utils_test.go:171 doesn't match the argument at index 2.
Got: &{application/merge-patch+json 0x1e25600 0xc00025b200 {false}}
Want: is equal to &{application/merge-patch+json 0x1e25600 0xc00025afc0 {false}}
Do you know why with the new version of controller-runtime it now fails with similar error ? I see kubernetes-sigs/controller-runtime#1406 but I cannot correlate it to the failure.
The reason I am asking is that currently the helper func test.EXPECTPatch
is always expecting a MergeFrom
PatchOption and I assume this func won't be useful if there is usage of StrategicMergeFrom
or anything other PatchOption.
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.
Do you know why with the new version of controller-runtime it now fails with similar error ? I see kubernetes-sigs/controller-runtime#1406 but I cannot correlate it to the failure.
This is explained in the commit message of 0fdab6e:
Due to kubernetes-sigs/controller-runtime#1413,
naive gomock expectations don't work anymore. The reason is that the
mergeFromPatch
struct has now a function attribute (createPatch
),
and asgomega
is usingreflect.DeepEqual
under the hood, the
comparison now fails:Func values are deeply equal if both are nil; otherwise they are not deeply equal.
(from https://golang.org/pkg/reflect/#DeepEqual)Hence, we introduce our own
test.EXPECTPatch()
function.Thanks to @timuthy for pointing this out.
I'm also not too happy with it and am very much open for better ideas.
The reason I am asking is that currently the helper func test.EXPECTPatch is always expecting a MergeFrom PatchOption and I assume this func won't be useful if there is usage of StrategicMergeFrom or anything other PatchOption.
Maybe, but we don't use StrategicMergeFrom
or any PatchOption
yet, so the function can be extended as soon as we need 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.
Ok, thanks for explaining. I guess the proper way to fix this is to adapt the createPatch
field from func to an interface in the upstream. I can have a look into this one with some lower prio. But yeah, it seems that it is out of the scope of this PR.
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, probably @timebertt can help here as the initial author of this change in k-sigs/controller-runtime :)
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 now opened kubernetes-sigs/controller-runtime#1439. Let me know if you have more elegant solution to the problem in mind.
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
/needs second-opinion
Due to kubernetes-sigs/controller-runtime#1413, naive gomock expectations don't work anymore. The reason is that the `mergeFromPatch` struct has now a function attribute (`createPatch`), and as `gomega` is using `reflect.DeepEqual` under the hood, the comparison now fails: > Func values are deeply equal if both are nil; otherwise they are not deeply equal. (from https://golang.org/pkg/reflect/#DeepEqual) Hence, we introduce our own `test.EXPECTPatch()` function. Thanks to @timuthy for pointing this out.
Rebased to resolve the conflicts. |
0ae1899
to
e98ce76
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
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
Thanks for cleaning up the forked code as well 👍
* make revendor generate * Get rid of third_party/forked/kubernetes * Adapt Patch() expectations of MockClient Due to kubernetes-sigs/controller-runtime#1413, naive gomock expectations don't work anymore. The reason is that the `mergeFromPatch` struct has now a function attribute (`createPatch`), and as `gomega` is using `reflect.DeepEqual` under the hood, the comparison now fails: > Func values are deeply equal if both are nil; otherwise they are not deeply equal. (from https://golang.org/pkg/reflect/#DeepEqual) Hence, we introduce our own `test.EXPECTPatch()` function. Thanks to @timuthy for pointing this out. * Adapt kubelet config
* make revendor generate * Get rid of third_party/forked/kubernetes * Adapt Patch() expectations of MockClient Due to kubernetes-sigs/controller-runtime#1413, naive gomock expectations don't work anymore. The reason is that the `mergeFromPatch` struct has now a function attribute (`createPatch`), and as `gomega` is using `reflect.DeepEqual` under the hood, the comparison now fails: > Func values are deeply equal if both are nil; otherwise they are not deeply equal. (from https://golang.org/pkg/reflect/#DeepEqual) Hence, we introduce our own `test.EXPECTPatch()` function. Thanks to @timuthy for pointing this out. * Adapt kubelet config
How to categorize this PR?
/area open-source quality
/kind task
/priority normal
What this PR does / why we need it:
This PR vendors all the Kubernetes dependencies in version
v0.20.2
andcontroller-runtime
versionv0.8.3
.Special notes for your reviewer:
/invite @timebertt @ialidzhikov
/squash
I got rid of our fork of
k8s.io/kube-openapi
and our pinning of- do you see issues with this?sigs.k8s.io/structured-merge-diff/v4
Release note: