-
Notifications
You must be signed in to change notification settings - Fork 464
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
[controller-manager] Switch ExposureClass
controller to controller-runtime
#6423
[controller-manager] Switch ExposureClass
controller to controller-runtime
#6423
Conversation
f667e59
to
a4ee1a4
Compare
a4ee1a4
to
cb3e4db
Compare
cb3e4db
to
c40753f
Compare
/test pull-gardener-e2e-kind |
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.
Had a combined look with @timebertt and @acumino.
Left some comments.
/assign @shafeeqes @acumino @timebertt
test/integration/controllermanager/exposureclass/exposureclass_suit_test.go
Outdated
Show resolved
Hide resolved
test/integration/controllermanager/exposureclass/exposureclass_test.go
Outdated
Show resolved
Hide resolved
pkg/controllermanager/controller/exposureclass/reconciler_test.go
Outdated
Show resolved
Hide resolved
pkg/controllermanager/controller/exposureclass/reconciler_test.go
Outdated
Show resolved
Hide resolved
Thanks! |
/test pull-gardener-e2e-kind-migration |
exposureClass = &gardencorev1alpha1.ExposureClass{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: resourceName, | ||
Namespace: testNamespace.Name, | ||
GenerateName: testID + "-", |
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.
With this, line 58 will be broken:
ExposureClassName: &exposureClass.Name, |
exposureClass.Name
is only populated once the object is created.
This means, there was never any shoot referencing the ExposureClass.
Considering that the test still passed despite this problem, you need to rework this case to test the right thing:
gardener/test/integration/controllermanager/exposureclass/exposureclass_test.go
Lines 138 to 143 in fca73ec
It("should add the finalizer and not release it on deletion since there is still referencing shoot", func() { | |
By("Ensure ExposureClass is not released") | |
Consistently(func() error { | |
return testClient.Get(ctx, client.ObjectKeyFromObject(exposureClass), exposureClass) | |
}).Should(Succeed()) | |
}) |
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.
While debugging the integration test and keeping a breakpoint at Line95 :
log.Info("Created Shoot for test", "shoot", client.ObjectKeyFromObject(shoot)) |
We found out that the shoot.Spec.ExposureClassName
is having the correct exposureClass.Name
value. This might be because shoot.Spec.ExposureClassName
is a pointer. WDYT ?
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.
Nice finding! You're right, that's why the test works because it is actually correct 😄
However, this is super implicit and error-prone.
I don't think there is any guarantee that the client decodes into the same field in memory, so you're basically making unsafe assumptions here.
Also, different objects should not share memory, which would have unwanted side effects during decoding.
So, in order to make this safe and explicit, I propose to drop line 58 and add the following after line 93
shoot.Spec.ExposureClassName = pointer.String(exposureClass.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.
Done in commit.
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.
Thank you!
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: timebertt 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 |
ExposureClass
controller to controller-runtime
* 'master' of github.com:gardener/gardener: (83 commits) Option to disable gardener shoot monitoring (gardener#6433) Switch ExposureClass controller to controller-runtime (gardener#6423) Exclude the proxy subresource from the KubeApiServerLatency alert and dashboard (gardener#6445) Collect filesystem metrics for the /run tmpfs mount point (gardener#6424) update CA image in charts for 1.22,1.21 and 1.20 (gardener#6449) Update redis test image to multi arch image (gardener#6446) Promote the `SecretBindingProviderValidation` feature gate to GA (gardener#6429) Upgrade K8s dependencies to v0.24.3 (gardener#6443) Enhance etcd readiness check (gardener#6434) Disables owner checks for clustered etcd (gardener#6412) Upgrade gardener/autoscaler (gardener#6428) Streamline integration tests (gardener#6398) Revert "Adapt `gardenlet` to use priority class `gardener-system-critical` (gardener#6235)" (gardener#6432) Improve validations on `shoots/binding` update (gardener#6416) Enforce that Shoot nginx-ingress addon and Seed VPA are not enabled for ManagedSeeds (gardener#6388) Switch Quota controller to controller-runtime (gardener#6391) Use multi-arch node-problem-detector image (gardener#6415) Reload kube-apiserver variable on dashboard time change (gardener#6407) [GRM] Label managed resources (gardener#6393) Adapt seed system components priority classes (gardener#6257) ...
ExposureClass
controller to controller-runtimeExposureClass
controller to controller-runtime
ExposureClass
controller to controller-runtimeExposureClass
controller to controller-runtime
How to categorize this PR?
/area dev-productivity scalability
/kind enhancement
What this PR does / why we need it:
Refactor the
ExposureClass
controller tocontroller-runtime
.Which issue(s) this PR fixes:
Part of #4251
Release note: