Skip to content

Commit 445c03f

Browse files
authored
Add flag for field export reconciler (#195)
Description of changes: - Add flag for field export reconciler By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent f850b7d commit 445c03f

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

pkg/config/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343

4444
const (
4545
flagEnableAdoptedResourceReconciler = "enable-adopted-resource-reconciler"
46+
flagEnableFieldExportReconciler = "enable-field-export-reconciler"
4647
flagEnableLeaderElection = "enable-leader-election"
4748
flagLeaderElectionNamespace = "leader-election-namespace"
4849
flagMetricAddr = "metrics-addr"
@@ -87,6 +88,7 @@ type Config struct {
8788
HealthzAddr string
8889
EnableLeaderElection bool
8990
EnableAdoptedResourceReconciler bool
91+
EnableFieldExportReconciler bool
9092
LeaderElectionNamespace string
9193
EnableDevelopmentLogging bool
9294
AccountID string
@@ -144,6 +146,11 @@ func (cfg *Config) BindFlags() {
144146
true,
145147
"Enable the AdoptedResource reconciler.",
146148
)
149+
flag.BoolVar(
150+
&cfg.EnableFieldExportReconciler, flagEnableFieldExportReconciler,
151+
true,
152+
"Enable the FieldExport reconciler.",
153+
)
147154
flag.StringVar(
148155
// In the context of the controller-runtime library, if the LeaderElectionNamespace parametere is not
149156
// explicitly set, the library will automatically default its value to the content of the file

pkg/runtime/service_controller.go

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,22 @@ func (c *serviceController) BindControllerManager(mgr ctrlrt.Manager, cfg ackcfg
258258
}
259259
}
260260

261-
exporterInstalled, err := c.GetFieldExportInstalled(mgr)
261+
exporterInstalled := false
262262
exporterLogger := c.log.WithName("exporter")
263-
if err != nil {
264-
exporterLogger.Error(err, "unable to determine if the FieldExport CRD is installed in the cluster")
265-
} else if !exporterInstalled {
266-
exporterLogger.Info("FieldExport CRD not installed. The field export reconciler will not be started")
267-
} else {
268-
rec := NewFieldExportReconcilerForFieldExport(c, exporterLogger, cfg, c.metrics, cache)
269-
if err := rec.BindControllerManager(mgr); err != nil {
270-
return err
263+
264+
if cfg.EnableFieldExportReconciler {
265+
exporterInstalled, err := c.GetFieldExportInstalled(mgr)
266+
if err != nil {
267+
exporterLogger.Error(err, "unable to determine if the FieldExport CRD is installed in the cluster")
268+
} else if !exporterInstalled {
269+
exporterLogger.Info("FieldExport CRD not installed. The field export reconciler will not be started")
270+
} else {
271+
rec := NewFieldExportReconcilerForFieldExport(c, exporterLogger, cfg, c.metrics, cache)
272+
if err := rec.BindControllerManager(mgr); err != nil {
273+
return err
274+
}
275+
c.fieldExportReconciler = rec
271276
}
272-
c.fieldExportReconciler = rec
273277
}
274278

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

308-
if exporterInstalled {
312+
if cfg.EnableFieldExportReconciler && exporterInstalled {
309313
rd := rmf.ResourceDescriptor()
310314
feRec := NewFieldExportReconcilerForAWSResource(c, exporterLogger, cfg, c.metrics, cache, rd)
311315
if err := feRec.BindControllerManager(mgr); err != nil {

0 commit comments

Comments
 (0)