Skip to content
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

Merged
merged 5 commits into from
Aug 4, 2022

Conversation

ary1992
Copy link
Contributor

@ary1992 ary1992 commented Aug 1, 2022

How to categorize this PR?

/area dev-productivity scalability
/kind enhancement

What this PR does / why we need it:
Refactor the ExposureClass controller to controller-runtime.

Which issue(s) this PR fixes:
Part of #4251

Release note:

NONE

@gardener-prow gardener-prow bot added area/dev-productivity Developer productivity related (how to improve development) area/scalability Scalability related kind/enhancement Enhancement, improvement, extension cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 1, 2022
@gardener-prow gardener-prow bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Aug 1, 2022
@ary1992 ary1992 force-pushed the refactor/exposureclass-ctrl branch from f667e59 to a4ee1a4 Compare August 1, 2022 09:44
@gardener-prow gardener-prow bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 1, 2022
@ary1992 ary1992 force-pushed the refactor/exposureclass-ctrl branch from a4ee1a4 to cb3e4db Compare August 1, 2022 11:13
@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 1, 2022
@ary1992 ary1992 force-pushed the refactor/exposureclass-ctrl branch from cb3e4db to c40753f Compare August 1, 2022 11:33
@acumino
Copy link
Member

acumino commented Aug 1, 2022

/test pull-gardener-e2e-kind

Copy link
Contributor

@shafeeqes shafeeqes left a 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

@ary1992 ary1992 requested a review from shafeeqes August 2, 2022 10:53
@shafeeqes
Copy link
Contributor

Thanks!
/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 2, 2022
@acumino
Copy link
Member

acumino commented Aug 2, 2022

/test pull-gardener-e2e-kind-migration

exposureClass = &gardencorev1alpha1.ExposureClass{
ObjectMeta: metav1.ObjectMeta{
Name: resourceName,
Namespace: testNamespace.Name,
GenerateName: testID + "-",
Copy link
Member

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:


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:

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())
})

Copy link
Contributor Author

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 ?

Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit.

@gardener-prow gardener-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2022
Copy link
Member

@timebertt timebertt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 4, 2022
@gardener-prow
Copy link
Contributor

gardener-prow bot commented Aug 4, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gardener-prow gardener-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 4, 2022
@gardener-prow gardener-prow bot merged commit c2640a1 into gardener:master Aug 4, 2022
@rfranzke rfranzke changed the title Switch ExposureClass controller to controller-runtime Switch ExposureClass controller to controller-runtime Sep 1, 2022
krgostev pushed a commit to krgostev/gardener that referenced this pull request Sep 8, 2022
* '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)
  ...
@rfranzke rfranzke changed the title Switch ExposureClass controller to controller-runtime [controller-manager] Switch ExposureClass controller to controller-runtime Sep 23, 2022
@rfranzke rfranzke changed the title [controller-manager] Switch ExposureClass controller to controller-runtime [controller-manager] Switch ExposureClass controller to controller-runtime Dec 14, 2022
@ary1992 ary1992 deleted the refactor/exposureclass-ctrl branch February 16, 2023 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/dev-productivity Developer productivity related (how to improve development) area/scalability Scalability related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants