Skip to content
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 @@ -43,6 +43,7 @@ import (

const (
flagEnableAdoptedResourceReconciler = "enable-adopted-resource-reconciler"
flagEnableFieldExportReconciler = "enable-field-export-reconciler"
flagEnableLeaderElection = "enable-leader-election"
flagLeaderElectionNamespace = "leader-election-namespace"
flagMetricAddr = "metrics-addr"
Expand Down Expand Up @@ -87,6 +88,7 @@ type Config struct {
HealthzAddr string
EnableLeaderElection bool
EnableAdoptedResourceReconciler bool
EnableFieldExportReconciler bool
LeaderElectionNamespace string
EnableDevelopmentLogging bool
AccountID string
Expand Down Expand Up @@ -144,6 +146,11 @@ func (cfg *Config) BindFlags() {
true,
"Enable the AdoptedResource reconciler.",
)
flag.BoolVar(
&cfg.EnableFieldExportReconciler, flagEnableFieldExportReconciler,
true,
"Enable the FieldExport reconciler.",
)
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
26 changes: 15 additions & 11 deletions pkg/runtime/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,22 @@ func (c *serviceController) BindControllerManager(mgr ctrlrt.Manager, cfg ackcfg
}
}

exporterInstalled, err := c.GetFieldExportInstalled(mgr)
exporterInstalled := false
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
exporterInstalled := false
exporterEnabled := false

you can then set it to True inside the if/else

exporterLogger := c.log.WithName("exporter")
if err != nil {
exporterLogger.Error(err, "unable to determine if the FieldExport CRD is installed in the cluster")
} else if !exporterInstalled {
exporterLogger.Info("FieldExport CRD not installed. The field export reconciler will not be started")
} else {
rec := NewFieldExportReconcilerForFieldExport(c, exporterLogger, cfg, c.metrics, cache)
if err := rec.BindControllerManager(mgr); err != nil {
return err

if cfg.EnableFieldExportReconciler {
exporterInstalled, err := c.GetFieldExportInstalled(mgr)
if err != nil {
exporterLogger.Error(err, "unable to determine if the FieldExport CRD is installed in the cluster")
} else if !exporterInstalled {
exporterLogger.Info("FieldExport CRD not installed. The field export reconciler will not be started")
} else {
rec := NewFieldExportReconcilerForFieldExport(c, exporterLogger, cfg, c.metrics, cache)
if err := rec.BindControllerManager(mgr); err != nil {
return err
}
c.fieldExportReconciler = rec
}
c.fieldExportReconciler = rec
}

// Get the list of resources to reconcile from the config
Expand Down Expand Up @@ -305,7 +309,7 @@ func (c *serviceController) BindControllerManager(mgr ctrlrt.Manager, cfg ackcfg
}
c.reconcilers = append(c.reconcilers, rec)

if exporterInstalled {
if cfg.EnableFieldExportReconciler && exporterInstalled {
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
if cfg.EnableFieldExportReconciler && exporterInstalled {
if exporterEnabled {

rd := rmf.ResourceDescriptor()
feRec := NewFieldExportReconcilerForAWSResource(c, exporterLogger, cfg, c.metrics, cache, rd)
if err := feRec.BindControllerManager(mgr); err != nil {
Expand Down