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

Add a new flag for enabling/disabling AdoptedResource reconciler #144

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import (
)

const (
flagEnableAdoptedResourceReconciler = "enable-adopted-resource-reconciler"
flagEnableLeaderElection = "enable-leader-election"
flagLeaderElectionNamespace = "leader-election-namespace"
flagMetricAddr = "metrics-addr"
Expand Down Expand Up @@ -79,6 +80,7 @@ type Config struct {
MetricsAddr string
HealthzAddr string
EnableLeaderElection bool
EnableAdoptedResourceReconciler bool
LeaderElectionNamespace string
EnableDevelopmentLogging bool
AccountID string
Expand Down Expand Up @@ -126,6 +128,11 @@ func (cfg *Config) BindFlags() {
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.",
)
flag.BoolVar(
&cfg.EnableAdoptedResourceReconciler, flagEnableAdoptedResourceReconciler,
true,
"Enable the AdoptedResource reconciler.",
)
Comment on lines +131 to +135
Copy link
Member Author

@a-hilaly a-hilaly Mar 25, 2024

Choose a reason for hiding this comment

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

Keeping the default to true for now. We should start thinking about deprecation and removal dates, once the adoption via annotation is supported

flag.StringVar(
// In the context of the controller-runtime library, if the LeaderElectionNamespace parametere is not
// explicitly set, the library will automatically default its value to the content of the file
Expand Down
24 changes: 13 additions & 11 deletions pkg/runtime/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,18 +235,20 @@ func (c *serviceController) BindControllerManager(mgr ctrlrt.Manager, cfg ackcfg
cache.Run(clientSet)
}

adoptionInstalled, err := c.GetAdoptedResourceInstalled(mgr)
adoptionLogger := c.log.WithName("adoption")
if err != nil {
adoptionLogger.Error(err, "unable to determine if the AdoptedResource CRD is installed in the cluster")
} else if !adoptionInstalled {
adoptionLogger.Info("AdoptedResource CRD not installed. The adoption reconciler will not be started")
} else {
rec := NewAdoptionReconciler(c, adoptionLogger, cfg, c.metrics, cache)
if err := rec.BindControllerManager(mgr); err != nil {
return err
if cfg.EnableAdoptedResourceReconciler {
adoptionInstalled, err := c.GetAdoptedResourceInstalled(mgr)
adoptionLogger := c.log.WithName("adoption")
if err != nil {
adoptionLogger.Error(err, "unable to determine if the AdoptedResource CRD is installed in the cluster")
} else if !adoptionInstalled {
adoptionLogger.Info("AdoptedResource CRD not installed. The adoption reconciler will not be started")
} else {
rec := NewAdoptionReconciler(c, adoptionLogger, cfg, c.metrics, cache)
if err := rec.BindControllerManager(mgr); err != nil {
return err
}
c.adoptionReconciler = rec
}
c.adoptionReconciler = rec
}

exporterInstalled, err := c.GetFieldExportInstalled(mgr)
Expand Down