-
Notifications
You must be signed in to change notification settings - Fork 169
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
Introduce an interface for controllers to improve consistency #3263
base: master
Are you sure you want to change the base?
Commits on Nov 9, 2023
-
operator: Let AROControllers configure their own loggers
Progressing toward not exporting controller name constants.
Matthew Barnes committedNov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for e397ee6 - Browse repository at this point
Copy the full SHA e397ee6View commit details -
operator: Introduce AROReconciler interface
Initial methods are geared toward controller registration: GetName() string SetupWithManager(ctrl.Manager) error All AROController subtypes must implement SetupWithManager.
Matthew Barnes committedNov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for 76934a5 - Browse repository at this point
Copy the full SHA 76934a5View commit details -
operator: Do not export controller name constants
Use AROReconciler.GetName instead.
Matthew Barnes committedNov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for 9660fb4 - Browse repository at this point
Copy the full SHA 9660fb4View commit details -
Matthew Barnes committed
Nov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for 03642e4 - Browse repository at this point
Copy the full SHA 03642e4View commit details -
operator: Add EnabledFlag field to AROController
Matthew Barnes committedNov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for f1b40b0 - Browse repository at this point
Copy the full SHA f1b40b0View commit details -
operator: Add reconcile methods to AROReconciler interface
This introduces two new methods in AROReconciler: ReconcileEnabled(ctx, request, cluster) -> (result, error) ReconcileDisabled(ctx, request, cluster) -> (result, error) One or the other method will be called based on the controller's "enabled" operator flag. AROController itself now implements the Reconcile method in order to consistently handle disabled controllers. Subtypes need only implement the ReconcileEnabled method, called when the controller is enabled. The Reconcile method uses the "template method" design pattern from object-oriented programming. This warrants some explanation since the pattern looks a little odd in Golang. Some background reading: https://golangbyexample.com/template-method-design-pattern-golang/ AROController provides ReconcileDisabled but leaves ReconcileEnabled unimplemented, so ReconcileEnabled is effectively an abstract method. Therefore AROController itself is not an AROReconciler according to Golang's interface semantics, but its subtypes are. Because AROController's Reconcile method calls ReconcileEnabled, which is abstract, it needs a way to cast itself to an AROReconciler. This is the purpose of the Reconciler field in AROController. The field is set during subtype instantiation: r := ExampleReconciler{ AROController: base.AROController { Log: ... Client: ... Name: ... EnabledFlag: ... } } r.Reconciler = r return r The Reconciler field is essentially a virtual method table like those inherent in polymorphic languages like C++ and Python. It allows AROController to call abstract AROReconciler methods that are implemented by a subtype.
Matthew Barnes committedNov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for 499680a - Browse repository at this point
Copy the full SHA 499680aView commit details -
operator: Add unit tests for AROController's Reconcile
Matthew Barnes committedNov 9, 2023 Configuration menu - View commit details
-
Copy full SHA for 3c6c252 - Browse repository at this point
Copy the full SHA 3c6c252View commit details