diff --git a/mgmt-agent/pkg/controller/resourcewatcher.go b/mgmt-agent/pkg/controller/resourcewatcher.go index 7be4ceb0923..943e25590e8 100644 --- a/mgmt-agent/pkg/controller/resourcewatcher.go +++ b/mgmt-agent/pkg/controller/resourcewatcher.go @@ -40,7 +40,7 @@ var watchedGroupSuffixes = []string{ "hypershift.openshift.io", "agent-install.openshift.io", "multicluster.openshift.io", - "multitenancy.acn.azure.com", + "acn.azure.com", "velero.io", } @@ -50,7 +50,8 @@ type ServerResourceDiscoverer interface { } // ResourceWatcher discovers API resources matching a set of group suffixes, also -// watches core/v1/namespaces, and logs every event via dynamic informers as structured JSON. +// watches core/v1/namespaces and core/v1/nodes, and logs every event via dynamic +// informers as structured JSON. type ResourceWatcher struct { dynamicClient dynamic.Interface discoveryClient ServerResourceDiscoverer @@ -64,11 +65,12 @@ func NewResourceWatcher(dynamicClient dynamic.Interface, discoveryClient ServerR } } -// Run discovers GVRs for the configured group suffixes, also watches core/v1/namespaces, -// starts dynamic informers for each, and blocks until the context is cancelled. Events are -// logged as structured JSON via klog. A CRD informer watches for new CustomResourceDefinitions; -// if a new CRD is registered whose group matches the watched suffixes and introduces -// GVRs not known at startup, the process exits so the pod restarts and picks them up. +// Run discovers GVRs for the configured group suffixes, also watches core/v1/namespaces +// and core/v1/nodes, starts dynamic informers for each, and blocks until the context is +// cancelled. Events are logged as structured JSON via klog. A CRD informer watches for new +// CustomResourceDefinitions; if a new CRD is registered whose group matches the watched +// suffixes and introduces GVRs not known at startup, the process exits so the pod restarts +// and picks them up. func (w *ResourceWatcher) Run(ctx context.Context) error { logger := klog.FromContext(ctx) logger.Info("Starting resource watcher") @@ -77,7 +79,10 @@ func (w *ResourceWatcher) Run(ctx context.Context) error { if err != nil { return err } - gvrs = append(gvrs, schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}) + gvrs = append(gvrs, + schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}, + schema.GroupVersionResource{Group: "", Version: "v1", Resource: "nodes"}, + ) logger.Info("Discovered resources to watch", "count", len(gvrs)) knownGVRs := sets.New[schema.GroupVersionResource](gvrs...) diff --git a/mgmt-agent/pkg/controller/resourcewatcher_test.go b/mgmt-agent/pkg/controller/resourcewatcher_test.go index cc1fd6dcc98..a2c2bacd96b 100644 --- a/mgmt-agent/pkg/controller/resourcewatcher_test.go +++ b/mgmt-agent/pkg/controller/resourcewatcher_test.go @@ -36,6 +36,7 @@ func TestMatchesGroupSuffix(t *testing.T) { {"agent-install.openshift.io", true}, {"capi-provider.agent-install.openshift.io", true}, {"multicluster.openshift.io", true}, + {"acn.azure.com", true}, {"multitenancy.acn.azure.com", true}, {"velero.io", true}, {"", false},