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 Bastion controller to controller-runtime and introduce common indexers #6358

Merged
merged 16 commits into from Jul 26, 2022

Conversation

rfranzke
Copy link
Member

@rfranzke rfranzke commented Jul 19, 2022

How to categorize this PR?

/area dev-productivity scalability
/kind enhancement

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

Also, introduce a new pkg/api/indexer package which hosts functions for adding field indexes to the controller-runtime cache.
The package is commonly used by controller-manager, gardenlet and integration tests, so that we can add indexes in symmetry and without duplication.

Partly co-authored by @timebertt.

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

Special notes for your reviewer:
Generally, we want to follow this cookbook while refactoring existing controllers:

  1. Add documentation
  2. Add integration test based on envtest
  3. Switch controller to controller-runtime

Release note:

Some signatures in `pkg/controllerutils/mapper` have changed to support the simple injection of a proper context and logger.

@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. labels Jul 19, 2022
@gardener-prow gardener-prow bot requested review from krgostev and wyb1 July 19, 2022 14:27
@gardener-prow gardener-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jul 19, 2022
Copy link
Contributor

@plkokanov plkokanov left a comment

Choose a reason for hiding this comment

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

Very nice PR! I just have a few questions.

@rfranzke rfranzke requested a review from plkokanov July 20, 2022 11:15
Copy link
Member

@oliver-goetz oliver-goetz left a comment

Choose a reason for hiding this comment

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

Shouldn't we create unit tests for pkg/api/indexer as it is a new package now? 😅

pkg/controllerutils/mapper/enqueue_mapped.go Outdated Show resolved Hide resolved
pkg/controllerutils/mapper/enqueue_mapped.go Outdated Show resolved Hide resolved
@timebertt
Copy link
Member

/assign
I will review this PR and also address the open suggestions, while @rfranzke is absent.

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 21, 2022
rfranzke and others added 12 commits July 21, 2022 16:17
Otherwise, IDEs might show an error that we don't import these packages "correctly".

Co-Authored-By: Tim Ebert <tim.ebert@sap.com>
This way, they will become reusable (e.g. for integration tests, see next commit).

Co-Authored-By: Tim Ebert <tim.ebert@sap.com>
Co-Authored-By: Tim Ebert <tim.ebert@sap.com>
This makes it easier to construct functions which can be casted via
`mapper.MapFunc` to the `mapper.Mapper` interface (see next commit).

Co-Authored-By: Tim Ebert <tim.ebert@sap.com>
Co-Authored-By: Tim Ebert <tim.ebert@sap.com>
This allows us to use one manager for all cases (next commit)
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.

Not completely through yet

pkg/api/indexer/core.go Show resolved Hide resolved
test/integration/controllermanager/bastion/bastion_test.go Outdated Show resolved Hide resolved
extensions/pkg/controller/backupbucket/controller.go Outdated Show resolved Hide resolved
@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 21, 2022
@timebertt timebertt requested a review from plkokanov July 22, 2022 06:02
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.

This is my remaining feedback

pkg/controllermanager/controller/bastion/add.go Outdated Show resolved Hide resolved
pkg/controllermanager/controller/bastion/add.go Outdated Show resolved Hide resolved
pkg/controllermanager/controller/bastion/add.go Outdated Show resolved Hide resolved
pkg/controllermanager/controller/bastion/add_test.go Outdated Show resolved Hide resolved
@timebertt
Copy link
Member

timebertt commented Jul 22, 2022

I have finished my review and pushed a few more commits addressing the open suggestions.
@oliver-goetz @plkokanov PTAL :)

Copy link
Member

@oliver-goetz oliver-goetz left a comment

Choose a reason for hiding this comment

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

The scope of this PR is now a bit bigger than its name and description suggests.
Maybe it is worth mentioning that the new common indexer functions are used by gardenlet too.

pkg/gardenlet/controller/factory.go Outdated Show resolved Hide resolved
@timebertt timebertt changed the title Switch Bastion controller to controller-runtime Switch Bastion controller to controller-runtime and introduce common indexers Jul 26, 2022
@timebertt
Copy link
Member

@oliver-goetz @plkokanov thanks for your feedback, PTAL :)

@gardener-prow
Copy link
Contributor

gardener-prow bot commented Jul 26, 2022

@rfranzke: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-gardener-apidiff 415afb0 link false /test pull-gardener-apidiff

Full PR test history. Your PR dashboard. Command help for this repository.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@plkokanov
Copy link
Contributor

/lgtm on my side

@oliver-goetz
Copy link
Member

/lgtm

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

/approve

@gardener-prow
Copy link
Contributor

gardener-prow bot commented Jul 26, 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 Jul 26, 2022
@@ -189,3 +209,60 @@ var _ = Describe("Add", func() {
})
})
})

// TODO: remove this again once the controller-runtime fake client supports field selectors
Copy link
Member Author

Choose a reason for hiding this comment

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

Is there already a PR for it or can you open one with this code? :)

Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, there is no PR for this upstream yet, AFAIK.
This will probably involve some design discussion, so expect some delay. But I will try my best :)

Copy link
Member Author

Choose a reason for hiding this comment

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

😄 Okay, thank you!

@acumino
Copy link
Member

acumino commented Jul 26, 2022

/milestone v1.52

@gardener-prow gardener-prow bot added this to the v1.52 milestone Jul 26, 2022
@oliver-goetz oliver-goetz added component/gardener Gardener and removed component/gardener Gardener labels Jul 26, 2022
@gardener-prow gardener-prow bot merged commit 5b34567 into gardener:master Jul 26, 2022
@rfranzke rfranzke deleted the refactor/bastion-ctrl branch July 26, 2022 15:50
@rfranzke rfranzke changed the title Switch Bastion controller to controller-runtime and introduce common indexers [controller-manager] Switch Bastion controller to controller-runtime and introduce common indexers Sep 23, 2022
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants