-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor operator resource reconciler to support resource153 + add la…
…bel propagation I initially just wanted to add label propagation (which is required for OpenSSH and OpenSSHEICE servers). However I ran into an issue: not all Teleport resources implement the `ResourceWithLabels` interface. Basically we have 4 cases: - resources implementing `ResourceWithLabels` (e.g. User, Role, ...) - resources implementing `ResourceWithOrigin` but not `ResourceWithLabels` (e.g. GitHub connector, ProvisionToken, ...) - resources that have been tweaked to implement only the operator `TeleportResource` interface (`LoginRule`) - resources implementing `Resource153` To support all those resoucres, we can either: - edit each resource so they expose the same methods (e.g. ProvisionToken exposes `GetLabels` instead of `GetStaticLabels`) - wrap each ressource in a wrapper that implements the operator TeleportResource interface - add multiple reconcilers, one for each resource kind I don't think it's sane for the operator to force changes on Teleport resources. Especially as those are known to be non consistent. I also don't want the operator to maintain a copy of each resource, this is not viable on the long term. For those reasons I chose the 3rd approach and built 3 reconcilers. Then I deducplicated the code to end up with a generic reconciler that can be tuned by passing an adapter. The adapter is an empty struct that has all the methods to extract the information the operator requires from the resource. The resulting PR is large and heavily uses generics but the amount of logical changes is quite low (the only diff is that we now copy labels). I can walk you through the PR if needed. With this PR, the operator supports properly any resource implementing `types.Resource153`, this will be useful to add `TeleportBotV1` support.
- Loading branch information
Showing
42 changed files
with
1,137 additions
and
803 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Teleport | ||
* Copyright (C) 2024 Gravitational, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package controllers | ||
|
||
import ( | ||
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
) | ||
|
||
// Reconciler extends the reconcile.Reconciler interface by adding a | ||
// SetupWithManager function that creates a controller in the given manager. | ||
// Every reconciler from the reconcilers package must implement this interface. | ||
type Reconciler interface { | ||
reconcile.Reconciler | ||
SetupWithManager(mgr manager.Manager) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.