Skip to content
Open
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
21 changes: 13 additions & 8 deletions mgmt-agent/pkg/controller/resourcewatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}

Expand All @@ -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
Expand All @@ -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")
Expand All @@ -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"},
)
Comment on lines +82 to +85

@SudoBrendan Brendan Bergen (SudoBrendan) Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is based on old kube (?). It was true at some point in the past that node status was incredibly noisy, but they fixed it AFAICT - https://github.com/kubernetes/enhancements/tree/master/keps/sig-node/589-efficient-node-heartbeats

IMO - if a Node status changes (regardless of frequency), SRE will really care about that, especially since it's expected that Node outages or remediations will be our primary course of action. This data is likely the most valuable thing for us to ship to logs - highlighting issues with capacity and connectivity.

In any case, I'm convinced Nodes will generate way less traffic than Events or Pods, which we already track.

logger.Info("Discovered resources to watch", "count", len(gvrs))

knownGVRs := sets.New[schema.GroupVersionResource](gvrs...)
Expand Down
1 change: 1 addition & 0 deletions mgmt-agent/pkg/controller/resourcewatcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Comment thread
ventifus marked this conversation as resolved.
{"", false},
Expand Down