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 remaining Project controllers to controller-runtime #6667

Merged
merged 7 commits into from
Sep 15, 2022

Conversation

rfranzke
Copy link
Member

How to categorize this PR?

/area dev-productivity scalability
/kind enhancement

What this PR does / why we need it:
Refactor the remaining Project controller to controller-runtime. The main reconciler was already refactored as part of #6645.

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

I successfully stress-tested both new integration tests against an existing Gardener system.

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. labels Sep 13, 2022
@gardener-prow gardener-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 13, 2022
@rfranzke
Copy link
Member Author

rfranzke commented Sep 13, 2022

@rfranzke: The following tests 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-check-vulnerabilities 2dcf326 link false /test pull-gardener-check-vulnerabilities
pull-gardener-e2e-kind 2dcf326 link true /test pull-gardener-e2e-kind
Full PR test history. Your PR dashboard. Command help for this repository. Please help us cut down on flakes by linking this test failure to an open flake report or filing a new flake report if you can't find an existing one. Also see our testing guideline for how to avoid and hunt flakes.

Opened #6669

/test pull-gardener-e2e-kind

@shafeeqes
Copy link
Contributor

/assign

@gardener-prow gardener-prow bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 13, 2022
@gardener-prow gardener-prow bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 14, 2022
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.

Very nice PR!
Few nits.

@shafeeqes
Copy link
Contributor

Thanks!
/lgtm

@gardener-prow gardener-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 14, 2022
@rfranzke
Copy link
Member Author

/approve

@gardener-prow
Copy link
Contributor

gardener-prow bot commented Sep 15, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rfranzke

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 Sep 15, 2022
@gardener-prow
Copy link
Contributor

gardener-prow bot commented Sep 15, 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-check-vulnerabilities 3c3ad53 link false /test pull-gardener-check-vulnerabilities

Full PR test history. Your PR dashboard. Command help for this repository.
Please help us cut down on flakes by linking this test failure to an open flake report or filing a new flake report if you can't find an existing one. Also see our testing guideline for how to avoid and hunt flakes.

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.

@rfranzke
Copy link
Member Author

/test pull-gardener-integration

ref #6679 (comment)

@gardener-prow gardener-prow bot merged commit 921370a into gardener:master Sep 15, 2022
@rfranzke rfranzke deleted the refactor/project-ctrl branch September 15, 2022 08:58
@rfranzke rfranzke changed the title Switch remaining Project controller to controller-runtime [controller-manager] Switch remaining Project controller to controller-runtime Sep 23, 2022
Comment on lines +128 to +142
UpdateFunc: func(e event.UpdateEvent) bool {
oldObjMeta, err := meta.Accessor(e.ObjectOld)
if err != nil {
return false
}

objMeta, err := meta.Accessor(e.ObjectNew)
if err != nil {
return false
}

_, oldObjHasLabel := oldObjMeta.GetLabels()[v1beta1constants.LabelSecretBindingReference]
_, newObjHasLabel := objMeta.GetLabels()[v1beta1constants.LabelSecretBindingReference]

return oldObjHasLabel && newObjHasLabel
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, it was like this,

func (c *Controller) projectActivityObjectUpdate(ctx context.Context, oldObj, newObj interface{}, withLabel bool) {
oldObjMeta, err := meta.Accessor(oldObj)
if err != nil {
return
}
newObjMeta, err := meta.Accessor(newObj)
if err != nil {
return
}
if withLabel {
// skip queueing if the object(secret or quota) doesn't have the "referred by a secretbinding" label
_, oldObjHasLabel := oldObjMeta.GetLabels()[v1beta1constants.LabelSecretBindingReference]
_, newObjHasLabel := newObjMeta.GetLabels()[v1beta1constants.LabelSecretBindingReference]
if !oldObjHasLabel && !newObjHasLabel {
return
}
} else if oldObjMeta.GetGeneration() == newObjMeta.GetGeneration() {
return
}

which is not the case now.
On simple words, we were acting if either of the object has the label. If the new doesn't have the label and the old had, which means the deletion of the last secretbinding referring this secret. Don't we want to consider this as "activity"?
If not, then we should only consider the newObject. The first time the secret is "referred" the oldObject won't have label, but we want to consider this as activity too.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't remember to have changed this on purpose, so probably it was a mistake. @shafeeqes can you open a PR to fix it and preserve the old behaviour?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, but should we consider the deletion of the last secretbinding (which can be in a different namespace) as an activity?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, let's consider it as activity 👍🏻

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, then I'll go ahead.

@rfranzke rfranzke changed the title [controller-manager] Switch remaining Project controller to controller-runtime [controller-manager] Switch remaining Project controllers to controller-runtime Nov 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

2 participants