feat(mgmt-agent): add configmap controller to watch swift router cm#6023
feat(mgmt-agent): add configmap controller to watch swift router cm#6023bennerv wants to merge 2 commits into
Conversation
…if ksm is enabled
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bennerv The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
This PR extends the mgmt-agent controller suite with a new ConfigMap watcher intended to observe the HyperShift “router” ConfigMap and log create/update/delete events to support routing-related troubleshooting.
Changes:
- Added
ConfigMapWatchercontroller using a typed ConfigMap informer with event handlers. - Wired the watcher and a dedicated informer factory into
mgmt-agent/cmd/options.goand started it under leader election. - Added basic unit tests for the new watcher.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| mgmt-agent/pkg/controller/cmwatcher.go | New ConfigMap watcher controller that logs ConfigMap lifecycle events (router CM). |
| mgmt-agent/pkg/controller/cmwatcher_test.go | Unit tests for the new watcher (construction + log function invocation). |
| mgmt-agent/cmd/options.go | Creates the ConfigMap-scoped informer factory and runs the watcher under leader election. |
| // ConfigMapWatcher watches ConfigMap resources using a typed informer and logs | ||
| // create, update, and delete events via structured logging. It is intended to | ||
| // be used with a field-selector-scoped informer factory so that only ConfigMaps | ||
| // with a specific label (e.g. "router") are watched. |
5d3a217 to
ad4a9f0
Compare
|
/hold
|
ad4a9f0 to
e47a797
Compare
| // The HyperShift router ConfigMap has no distinguishing labels, so we select by name. | ||
| const RouterConfigMapName = "router" |
|
/hold cancel looks good. |
|
/retest |
| return nil | ||
| } | ||
|
|
||
| func logConfigMapEvent(eventType string, cm *corev1.ConfigMap) { |
There was a problem hiding this comment.
can you add
cm.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("ConfigMap"))by default the serialization of cm here won't have apiVersion * kind fields
|
/retest |
2 similar comments
|
/retest |
|
/retest |
e47a797 to
f5b6301
Compare
| func logConfigMapEvent(eventType string, cm *corev1.ConfigMap) { | ||
| cm.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("ConfigMap")) | ||
| klog.InfoS("configmap event", | ||
| "event", eventType, | ||
| "namespace", cm.Namespace, | ||
| "name", cm.Name, | ||
| "object", cm, | ||
| ) | ||
| } |
| for _, tt := range tests { | ||
| t.Run(tt.name, func(t *testing.T) { | ||
| logConfigMapEvent(tt.eventType, tt.cm) | ||
| }) | ||
| } |
| func TestNewConfigMapWatcher(t *testing.T) { | ||
| clientset := fake.NewSimpleClientset() | ||
| factory := kubeinformers.NewSharedInformerFactory(clientset, 0) | ||
|
|
||
| w, err := NewConfigMapWatcher(factory.Core().V1().ConfigMaps()) | ||
| if err != nil { | ||
| t.Fatalf("NewConfigMapWatcher() returned error: %v", err) | ||
| } | ||
| if w == nil { | ||
| t.Fatal("NewConfigMapWatcher() returned nil") | ||
| } | ||
| if w.cmSynced == nil { | ||
| t.Fatal("NewConfigMapWatcher() did not set cmSynced") | ||
| } | ||
| } |
|
/retest |
|
/test all |
|
@bennerv: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Builds +1 commit on #6022
What
Adds a configmap controller to the mgmt-agent which watches the swift router configmap.
Why
Will help agentic AI troubleshoot issues with routing to KAS, oauth, ignition, konnectivity as well as us debug / troubleshoot.
Testing
Testing is required for feature completion and tests should be part of the pull
request along with the feature changes.
Describe the testing provided. If you did not add tests, provide a clear
justification.
Special notes for your reviewer
PR Checklist
If E2E tests are included:
demonstrate that the test is able to detect a defect/error and fail with
proper error message and logs which communicates nature of the problem.