Skip to content

feat(mgmt-agent): add configmap controller to watch swift router cm#6023

Open
bennerv wants to merge 2 commits into
Azure:mainfrom
bennerv:mgmt-agent-watch-swift-cm
Open

feat(mgmt-agent): add configmap controller to watch swift router cm#6023
bennerv wants to merge 2 commits into
Azure:mainfrom
bennerv:mgmt-agent-watch-swift-cm

Conversation

@bennerv

@bennerv bennerv commented Jul 10, 2026

Copy link
Copy Markdown
Member

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

  • PR is scoped to a single task (no mixed concerns)
  • Title follows Conventional Commits format
  • Summary explains the "Why" behind the change
  • Linked to relevant ticket/issue
  • Screenshots included (if graph/UI/metrics changes)
  • Self-reviewed the diff
  • CI/CD checks are passing (ignore Tide)
  • Draft PR used for WIP (if applicable)
  • Commit history is clean (rebased/squashed)
  • Tricky code blocks are commented
  • Specific reviewers tagged
  • All comment threads resolved before merge

If E2E tests are included:

  • E2E tests follow Principles of Good E2E Test Case Design
  • If new E2E use case is covered (via a new test or new check/verifier),
    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.

Copilot AI review requested due to automatic review settings July 10, 2026 22:08
@openshift-ci openshift-ci Bot requested review from raelga and stevekuznetsov July 10, 2026 22:09
@openshift-ci

openshift-ci Bot commented Jul 10, 2026

Copy link
Copy Markdown

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 ConfigMapWatcher controller using a typed ConfigMap informer with event handlers.
  • Wired the watcher and a dedicated informer factory into mgmt-agent/cmd/options.go and 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.

Comment thread mgmt-agent/pkg/controller/cmwatcher.go Outdated
Comment on lines +30 to +33
// 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.
Comment thread mgmt-agent/pkg/controller/cmwatcher.go
Comment thread mgmt-agent/pkg/controller/cmwatcher.go
Comment thread mgmt-agent/cmd/options.go Outdated
Copilot AI review requested due to automatic review settings July 10, 2026 22:14
@bennerv bennerv force-pushed the mgmt-agent-watch-swift-cm branch from 5d3a217 to ad4a9f0 Compare July 10, 2026 22:14
@bennerv

bennerv commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

/hold

  • confirm field selector is on apiserver side
  • as a result, smaller controller cache.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

Comment thread mgmt-agent/pkg/controller/cmwatcher.go Outdated
Comment thread mgmt-agent/pkg/controller/cmwatcher_test.go Outdated
Comment thread mgmt-agent/pkg/controller/cmwatcher_test.go Outdated
Comment thread mgmt-agent/pkg/controller/cmwatcher_test.go Outdated
Copilot AI review requested due to automatic review settings July 10, 2026 22:52
@bennerv bennerv force-pushed the mgmt-agent-watch-swift-cm branch from ad4a9f0 to e47a797 Compare July 10, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment on lines +27 to +28
// The HyperShift router ConfigMap has no distinguishing labels, so we select by name.
const RouterConfigMapName = "router"
@bennerv

bennerv commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

/hold cancel

looks good.

{"time":"2026-07-10T22:19:19.977133764Z","level":"INFO","source":{"function":"github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller.logConfigMapEvent","file":"/app/mgmt-agent/pkg/controller/cmwatcher.go","line":97},"msg":"configmap event","event":"Add","namespace":"ocm-arohcppers-2rfhh895c2l3eaed01asv15rimfo5dm9-e3m2t3d4r2c2m2n","name":"router","object":{"metadata":{"name":"router","namespace":"ocm-arohcppers-2rfhh895c2l3eaed01asv15rimfo5dm9-e3m2t3d4r2c2m2n","uid":"8dcddc7a-6424-4190-becd-6ba26ec157a1","resourceVersion":"1009971","creationTimestamp":"2026-07-10T22:19:19Z","ownerReferences":[{"apiVersion":"hypershift.openshift.io/v1beta1","kind":"HostedControlPlane","name":"e3m2t3d4r2c2m2n","uid":"a30063b0-5e8f-4c04-bedd-75fe79c6fc80","controller":true,"blockOwnerDeletion":true}],"managedFields":[{"manager":"hypershift-controlplane-manager","operation":"Update","apiVersion":"v1","time":"2026-07-10T22:19:19Z","fieldsType":"FieldsV1","fieldsV1":{"f:data":{".":{},"f:haproxy.cfg":{}},"f:metadata":{"f:ownerReferences":{".":{},"k:{\"uid\":\"a30063b0-5e8f-4c04-bedd-75fe79c6fc80\"}":{}}}}}]},"data":{"haproxy.cfg":"global\n  log stdout local0\n  maxconn 20000\n\ndefaults\n  mode tcp\n  log global\n  log-format \"%ci:%cp -> %fi:%fp [%t] %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq\"\n  option  dontlognull\n  retries 3\n  timeout http-request 30s\n  timeout queue        1m\n  timeout connect      10s\n  timeout client       86400s\n  timeout server       86400s\n  timeout tunnel       86400s\n\nresolvers azure_dns\n  nameserver azure 168.63.129.16:53\n\nfrontend main\n  bind :::8443 v4v6\n  tcp-request inspect-delay 5s\n  tcp-request content accept if { req_ssl_hello_type 1 }\n  acl is_ignition req_ssl_sni -i ignition-server.apps.e3m2t3d4r2c2m2n.hypershift.local\n  acl is_konnectivity req_ssl_sni -i konnectivity-server.apps.e3m2t3d4r2c2m2n.hypershift.local\n  acl is_keyvault req_ssl_sni -i cust-kv-ucdeewzzrgy6c.vault.azure.net\n  use_backend ignition if is_ignition\n  use_backend konnectivity if is_konnectivity\n  use_backend keyvault if is_keyvault\n  default_backend kube_api\n\nlisten health_check_http_url\n  bind :::9444 v4v6\n  mode http\n  monitor-uri /haproxy_ready\n\nbackend ignition\n  server ignition 10.130.206.111:443\n\nbackend konnectivity\n  server konnectivity 10.130.218.133:8091\n\nbackend kube_api\n  server kube_api 10.130.201.218:6443\n\nbackend keyvault\n  mode tcp\n  server kv cust-kv-ucdeewzzrgy6c.vault.azure.net:443 resolvers azure_dns\n"}}}
{"time":"2026-07-10T22:25:51.892999971Z","level":"INFO","source":{"function":"github.com/Azure/ARO-HCP/mgmt-agent/pkg/controller.logConfigMapEvent","file":"/app/mgmt-agent/pkg/controller/cmwatcher.go","line":97},"msg":"configmap event","event":"Update","namespace":"ocm-arohcppers-2rfhh895c2l3eaed01asv15rimfo5dm9-e3m2t3d4r2c2m2n","name":"router","object":{"metadata":{"name":"router","namespace":"ocm-arohcppers-2rfhh895c2l3eaed01asv15rimfo5dm9-e3m2t3d4r2c2m2n","uid":"8dcddc7a-6424-4190-becd-6ba26ec157a1","resourceVersion":"1009971","creationTimestamp":"2026-07-10T22:19:19Z","ownerReferences":[{"apiVersion":"hypershift.openshift.io/v1beta1","kind":"HostedControlPlane","name":"e3m2t3d4r2c2m2n","uid":"a30063b0-5e8f-4c04-bedd-75fe79c6fc80","controller":true,"blockOwnerDeletion":true}],"managedFields":[{"manager":"hypershift-controlplane-manager","operation":"Update","apiVersion":"v1","time":"2026-07-10T22:19:19Z","fieldsType":"FieldsV1","fieldsV1":{"f:data":{".":{},"f:haproxy.cfg":{}},"f:metadata":{"f:ownerReferences":{".":{},"k:{\"uid\":\"a30063b0-5e8f-4c04-bedd-75fe79c6fc80\"}":{}}}}}]},"data":{"haproxy.cfg":"global\n  log stdout local0\n  maxconn 20000\n\ndefaults\n  mode tcp\n  log global\n  log-format \"%ci:%cp -> %fi:%fp [%t] %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq\"\n  option  dontlognull\n  retries 3\n  timeout http-request 30s\n  timeout queue        1m\n  timeout connect      10s\n  timeout client       86400s\n  timeout server       86400s\n  timeout tunnel       86400s\n\nresolvers azure_dns\n  nameserver azure 168.63.129.16:53\n\nfrontend main\n  bind :::8443 v4v6\n  tcp-request inspect-delay 5s\n  tcp-request content accept if { req_ssl_hello_type 1 }\n  acl is_ignition req_ssl_sni -i ignition-server.apps.e3m2t3d4r2c2m2n.hypershift.local\n  acl is_konnectivity req_ssl_sni -i konnectivity-server.apps.e3m2t3d4r2c2m2n.hypershift.local\n  acl is_keyvault req_ssl_sni -i cust-kv-ucdeewzzrgy6c.vault.azure.net\n  use_backend ignition if is_ignition\n  use_backend konnectivity if is_konnectivity\n  use_backend keyvault if is_keyvault\n  default_backend kube_api\n\nlisten health_check_http_url\n  bind :::9444 v4v6\n  mode http\n  monitor-uri /haproxy_ready\n\nbackend ignition\n  server ignition 10.130.206.111:443\n\nbackend konnectivity\n  server konnectivity 10.130.218.133:8091\n\nbackend kube_api\n  server kube_api 10.130.201.218:6443\n\nbackend keyvault\n  mode tcp\n  server kv cust-kv-ucdeewzzrgy6c.vault.azure.net:443 resolvers azure_dns\n"}}}

@bennerv

bennerv commented Jul 11, 2026

Copy link
Copy Markdown
Member Author

/retest

return nil
}

func logConfigMapEvent(eventType string, cm *corev1.ConfigMap) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you add

cm.SetGroupVersionKind(corev1.SchemeGroupVersion.WithKind("ConfigMap"))

by default the serialization of cm here won't have apiVersion * kind fields

@stevekuznetsov

Copy link
Copy Markdown
Contributor

/retest

2 similar comments
@stevekuznetsov

Copy link
Copy Markdown
Contributor

/retest

@stevekuznetsov

Copy link
Copy Markdown
Contributor

/retest

@bennerv bennerv force-pushed the mgmt-agent-watch-swift-cm branch from e47a797 to f5b6301 Compare July 11, 2026 14:25
Copilot AI review requested due to automatic review settings July 11, 2026 14:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment on lines +94 to +102
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,
)
}
Comment on lines +67 to +71
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
logConfigMapEvent(tt.eventType, tt.cm)
})
}
Comment on lines +74 to +88
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")
}
}
@stevekuznetsov

Copy link
Copy Markdown
Contributor

/retest

@stevekuznetsov

Copy link
Copy Markdown
Contributor

/test all

@openshift-ci

openshift-ci Bot commented Jul 11, 2026

Copy link
Copy Markdown

@bennerv: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/periodic-healthcheck-images e47a797 link true /test periodic-healthcheck-images
ci/prow/image-updater-images e47a797 link true /test image-updater-images
ci/prow/e2e-parallel f5b6301 link true /test e2e-parallel
ci/prow/integration f5b6301 link true /test integration
ci/prow/test-unit f5b6301 link true /test test-unit
ci/prow/lint f5b6301 link true /test lint
ci/prow/config-change-detection f5b6301 link true /test config-change-detection

Full PR test history. Your PR dashboard.

Details

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants