diff --git a/internal/framework/controller/register.go b/internal/framework/controller/register.go index dc4c6e0f3..09bd69577 100644 --- a/internal/framework/controller/register.go +++ b/internal/framework/controller/register.go @@ -84,6 +84,7 @@ func defaultConfig() config { func Register( ctx context.Context, objectType ngftypes.ObjectType, + name string, mgr manager.Manager, eventCh chan<- interface{}, options ...Option, @@ -114,7 +115,7 @@ func Register( forOpts = append(forOpts, ctlrBuilder.OnlyMetadata) } - builder := ctlr.NewControllerManagedBy(mgr).For(objectType, forOpts...) + builder := ctlr.NewControllerManagedBy(mgr).Named(name).For(objectType, forOpts...) if cfg.k8sPredicate != nil { builder = builder.WithEventFilter(cfg.k8sPredicate) diff --git a/internal/framework/controller/register_test.go b/internal/framework/controller/register_test.go index 049bc727b..43ed032c7 100644 --- a/internal/framework/controller/register_test.go +++ b/internal/framework/controller/register_test.go @@ -139,6 +139,7 @@ func TestRegister(t *testing.T) { return controller.Register( context.Background(), test.objectType, + test.msg, // unique controller name for each loop iteration test.fakes.mgr, eventCh, controller.WithNamespacedNameFilter(nsNameFilter), diff --git a/internal/mode/provisioner/manager.go b/internal/mode/provisioner/manager.go index 13924e696..1052120d1 100644 --- a/internal/mode/provisioner/manager.go +++ b/internal/mode/provisioner/manager.go @@ -94,6 +94,7 @@ func StartManager(cfg Config) error { if err := controller.Register( ctx, regCfg.objectType, + regCfg.objectType.GetObjectKind().GroupVersionKind().Kind, mgr, eventCh, regCfg.options..., diff --git a/internal/mode/static/manager.go b/internal/mode/static/manager.go index 217b80af4..808e0f410 100644 --- a/internal/mode/static/manager.go +++ b/internal/mode/static/manager.go @@ -356,6 +356,7 @@ func registerControllers( controlConfigNSName types.NamespacedName, ) error { type ctlrCfg struct { + name string objectType ngftypes.ObjectType options []controller.Option } @@ -402,12 +403,14 @@ func registerControllers( }, { objectType: &apiv1.Service{}, + name: "user-service", options: []controller.Option{ controller.WithK8sPredicate(predicate.ServicePortsChangedPredicate{}), }, }, { objectType: &apiv1.Service{}, + name: "ngf-service", options: func() []controller.Option { svcNSName := types.NamespacedName{ Namespace: cfg.GatewayPodConfig.Namespace, @@ -521,9 +524,15 @@ func registerControllers( } for _, regCfg := range controllerRegCfgs { + name := regCfg.objectType.GetObjectKind().GroupVersionKind().Kind + if regCfg.name != "" { + name = regCfg.name + } + if err := controller.Register( ctx, regCfg.objectType, + name, mgr, eventCh, regCfg.options...,