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 @@ -45,6 +45,7 @@ const (
flagEnableAdoptedResourceReconciler = "enable-adopted-resource-reconciler"
flagEnableFieldExportReconciler = "enable-field-export-reconciler"
flagEnableLeaderElection = "enable-leader-election"
flagEnableCARM = "enable-carm"
flagLeaderElectionNamespace = "leader-election-namespace"
flagMetricAddr = "metrics-addr"
flagHealthzAddr = "healthz-addr"
Expand Down Expand Up @@ -89,6 +90,7 @@ type Config struct {
EnableLeaderElection bool
EnableAdoptedResourceReconciler bool
EnableFieldExportReconciler bool
EnableCARM bool
LeaderElectionNamespace string
EnableDevelopmentLogging bool
AccountID string
Expand Down Expand Up @@ -151,6 +153,11 @@ func (cfg *Config) BindFlags() {
true,
"Enable the FieldExport reconciler.",
)
flag.BoolVar(
&cfg.EnableCARM, flagEnableCARM,
true,
"Enable Cross Account Resource Management.",
)
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
11 changes: 3 additions & 8 deletions pkg/runtime/service_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,9 @@ func (c *serviceController) BindControllerManager(mgr ctrlrt.Manager, cfg ackcfg
}},
cfg.FeatureGates,
)
// We want to run the caches if the length of the namespaces slice is
// either 0 (watching all namespaces) or greater than 1 (watching multiple
// namespaces).
//
// The caches are only used for cross account resource management. If the
// controller is not configured to watch multiple namespaces, then we don't
// need to run the caches.
if len(namespaces) == 0 || len(namespaces) >= 2 {
// The caches are only used for cross account resource management. We
// want to run them only when --enable-carm is set to true.
if cfg.EnableCARM {
clusterConfig := mgr.GetConfig()
clientSet, err := kubernetes.NewForConfig(clusterConfig)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/runtime/service_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ func TestServiceController(t *testing.T) {

mgr := &fakeManager{}
cfg := ackcfg.Config{
// Disable caches, by setting a mono-namespace watch mode
WatchNamespace: "default",
// Disable caches, by setting EnableCARM to false
EnableCARM: false,
}
err := sc.BindControllerManager(mgr, cfg)
require.Nil(err)
Expand Down