Skip to content

feat: watch AuthenticationConfig CM changes#46

Open
Zaggy21 wants to merge 15 commits intomainfrom
feat/watch-authenticationconfig-cm-changes
Open

feat: watch AuthenticationConfig CM changes#46
Zaggy21 wants to merge 15 commits intomainfrom
feat/watch-authenticationconfig-cm-changes

Conversation

@Zaggy21
Copy link
Copy Markdown
Contributor

@Zaggy21 Zaggy21 commented Apr 24, 2026

This PR adds two related behaviours:

1. Auth CM labeling on first interaction When authenticationConfigMapName is configured, the shoot controller now labels the referenced Greenhouse ConfigMap with:

  • shoot-grafter.cloudoperators.dev/auth-configmap: "true" — marks it as an auth CM
  • shoot-grafter.cloudoperators.dev/careinstruction: <ci-name> — associates it with the owning CareInstruction

2. Watch-triggered reconciliation The shoot controller now watches labeled auth ConfigMaps on the Greenhouse cluster using source.Kind with the Greenhouse manager's cache. When an auth CM changes, all matching Shoots are immediately re-enqueued, keeping the Garden-side OIDC configuration in sync.

Added tests and updated docs.

The authentication ConfigMap label key is changed from shoot-grafter.cloudoperators/authconfigmap to shoot-grafter.cloudoperators.dev/auth-configmap. The new label will be added automatically on shoot reconciliation.

Zaggy21 added 4 commits April 24, 2026 11:23
…enhouse auth CM changes

On-behalf-of: @SAP krzysztof.zagorski@sap.com
…iggered reconciliation

On-behalf-of: @SAP krzysztof.zagorski@sap.com
@Zaggy21 Zaggy21 requested a review from a team as a code owner April 24, 2026 12:30
@Zaggy21 Zaggy21 linked an issue Apr 24, 2026 that may be closed by this pull request
4 tasks
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds cross-cluster reconciliation for Shoot OIDC configuration by labeling referenced Greenhouse AuthenticationConfiguration ConfigMaps and watching them for changes, so matching Shoots are re-enqueued when the auth ConfigMap updates.

Changes:

  • Label Greenhouse auth ConfigMaps on first interaction with AuthConfigMapLabel and CareInstructionLabel.
  • Add a Greenhouse-cache-backed watch to the Shoot controller to re-enqueue matching Shoots on auth ConfigMap changes.
  • Extend tests and update README documentation for the new labeling + watch behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
controller/shoot/shoot_controller.go Adds Greenhouse ConfigMap watch and re-enqueue mapping for Shoots.
controller/shoot/auth.go Adds CareInstruction ownership labeling to the referenced Greenhouse auth ConfigMap.
controller/careinstruction/careinstruction_controller.go Passes the Greenhouse manager into ShootController so it can watch Greenhouse resources.
controller/shoot/shoot_controller_test.go Starts the Greenhouse manager in tests and adds watch-triggered reconciliation coverage.
README.md Documents auth ConfigMap labeling + watch behavior and updates related references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread controller/shoot/shoot_controller_test.go
Comment thread README.md
Comment thread controller/shoot/auth.go
Comment thread controller/shoot/auth.go Outdated
Comment thread controller/shoot/shoot_controller.go Outdated
Comment thread controller/shoot/shoot_controller_test.go Outdated
Zaggy21 added 5 commits April 27, 2026 16:27
On-behalf-of: @SAP krzysztof.zagorski@sap.com
On-behalf-of: @SAP krzysztof.zagorski@sap.com
On-behalf-of: @SAP krzysztof.zagorski@sap.com
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds cross-cluster watch support so changes to a labeled Greenhouse AuthenticationConfiguration ConfigMap trigger immediate re-reconciliation of affected Shoots, keeping Garden-side OIDC configuration up to date. It also ensures the referenced auth ConfigMap is labeled on first interaction to make the watch predicate work.

Changes:

  • Label Greenhouse auth ConfigMaps with authconfigmap=true and the owning careinstruction=<name> on first use (via merge-patch).
  • Add a Greenhouse-cache-backed watch in the Shoot controller to re-enqueue matching Shoots on auth ConfigMap changes.
  • Extend controller tests and update README documentation for the labeling/watch behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
controller/shoot/shoot_controller.go Adds Greenhouse ConfigMap watch + enqueue mapping for watch-triggered reconciles.
controller/shoot/auth.go Switches to merge-patching labels and adds CareInstruction ownership label logic.
controller/careinstruction/careinstruction_controller.go Passes Greenhouse manager into ShootController to enable cross-cluster watches.
controller/shoot/shoot_controller_test.go Starts Greenhouse manager/cache for tests and adds watch-triggered reconciliation coverage.
api/v1alpha1/careinstruction_types.go Unifies auth ConfigMap label key under shoot-grafter.cloudoperators.dev.
README.md Documents labeling + watch behavior and updates OIDC doc link.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread controller/shoot/shoot_controller.go
Comment thread README.md Outdated
Zaggy21 added 2 commits April 28, 2026 15:29
On-behalf-of: @SAP krzysztof.zagorski@sap.com
…auth-configmap

On-behalf-of: @SAP krzysztof.zagorski@sap.com
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves OIDC AuthenticationConfiguration synchronization by labeling the referenced Greenhouse auth ConfigMap on first interaction and adding a Greenhouse-cache-backed watch that re-enqueues matching Shoots when that ConfigMap changes. It also standardizes the auth ConfigMap label key under the shoot-grafter.cloudoperators.dev prefix and updates docs/tests accordingly.

Changes:

  • Add labeling of Greenhouse AuthenticationConfiguration ConfigMaps with auth-configmap=true and the owning careinstruction label (using a merge patch).
  • Add a Greenhouse ConfigMap watch (via Greenhouse manager cache) to trigger immediate re-reconciliation of matching Shoots on auth CM updates.
  • Update label key constant + README and extend tests to cover labeling and watch-triggered reconciliation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
controller/shoot/shoot_controller.go Adds cross-cluster ConfigMap watch and re-enqueue mapping for matching Shoots.
controller/shoot/auth.go Switches to merge-patching labels and adds CareInstruction ownership labeling with conflict handling.
controller/shoot/shoot_controller_test.go Starts/syncs Greenhouse manager cache and adds tests for labeling + watch-triggered reconciliation.
controller/careinstruction/careinstruction_controller.go Wires Greenhouse manager into ShootController for cross-cluster watches.
api/v1alpha1/careinstruction_types.go Updates the auth ConfigMap label key constant to the new .dev/auth-configmap value.
README.md Documents new labeling/watch behavior and updates OIDC doc link + field description.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread controller/shoot/shoot_controller.go Outdated
Comment thread controller/shoot/shoot_controller_test.go
…nager context in tests

On-behalf-of: @SAP krzysztof.zagorski@sap.com
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Shoot controller to keep Garden-side OIDC authentication configuration in sync with a referenced Greenhouse AuthenticationConfiguration ConfigMap by (1) labeling the ConfigMap on first interaction and (2) reconciling Shoots when that labeled ConfigMap changes.

Changes:

  • Add labeling of the referenced Greenhouse auth ConfigMap with both an “auth CM” label and an owning CareInstruction label.
  • Add a cross-cluster watch (via the Greenhouse manager cache) that re-enqueues all matching Shoots when the labeled auth ConfigMap changes.
  • Update the auth ConfigMap label key constant, tests, and README documentation accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
controller/shoot/shoot_controller.go Adds Greenhouse cache-backed ConfigMap watch and re-enqueue mapping for auth ConfigMap changes.
controller/shoot/auth.go Patches Greenhouse auth ConfigMap labels (auth + careinstruction) without overwriting data.
controller/careinstruction/careinstruction_controller.go Passes the Greenhouse manager into the ShootController for cross-cluster watches.
api/v1alpha1/careinstruction_types.go Renames the auth ConfigMap label key to the .dev/auth-configmap form.
controller/shoot/shoot_controller_test.go Starts/syncs the Greenhouse manager cache in tests and adds watch-triggered reconciliation coverage.
README.md Documents labeling + watch behavior and updates the referenced Greenhouse docs link.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread controller/shoot/shoot_controller.go
Zaggy21 added 2 commits April 29, 2026 15:24
On-behalf-of: @SAP krzysztof.zagorski@sap.com
@github-actions
Copy link
Copy Markdown

Merging this branch will not change overall coverage

Impacted Packages Coverage Δ 🤖
github.com/cloudoperators/shoot-grafter/api/v1alpha1 0.00% (ø)
github.com/cloudoperators/shoot-grafter/controller/careinstruction 0.00% (ø)
github.com/cloudoperators/shoot-grafter/controller/shoot 0.00% (ø)

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/cloudoperators/shoot-grafter/api/v1alpha1/careinstruction_types.go 0.00% (ø) 0 0 0
github.com/cloudoperators/shoot-grafter/controller/careinstruction/careinstruction_controller.go 0.00% (ø) 0 0 0
github.com/cloudoperators/shoot-grafter/controller/shoot/auth.go 0.00% (ø) 0 0 0
github.com/cloudoperators/shoot-grafter/controller/shoot/shoot_controller.go 0.00% (ø) 0 0 0

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/cloudoperators/shoot-grafter/controller/shoot/shoot_controller_test.go

// GreenhouseMgr is passed so the ShootController can watch Greenhouse cluster resources (e.g. auth CMs).
sc := &shoot.ShootController{
GreenhouseClient: r.Client,
GreenhouseMgr: r.Manager,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am not super convinced that watching resources on two different Clusters is the way to go here.
I would opt to actually watch the CM changes in the CareInstruction controller for separation of concerns.
That would involve:

Looping in @abhijith-darshan for his opinion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT shoot-grafter] - Watch AuthenticationConfig CM changes

3 participants