OCPBUGS-81741: Watch Network and Infrastructure in proxyconfig controller#2968
OCPBUGS-81741: Watch Network and Infrastructure in proxyconfig controller#2968jluhrsen wants to merge 1 commit into
Conversation
|
@jluhrsen: This pull request references Jira Issue OCPBUGS-81741, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: openshift/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughAdds Proxy to the fake client's status subresources, registers watches for configv1.Network and configv1.Infrastructure in the proxy controller, adjusts reconcile dispatch/logging for cluster-scoped requests, and adds tests verifying Proxy.Status.NoProxy updates and error handling. ChangesProxy status and watches
Sequence Diagram(s)sequenceDiagram
participant Network as Network (configv1)
participant Infrastructure as Infrastructure (configv1)
participant Controller as Controller
participant Reconciler as Reconciler
participant Proxy as Proxy (configv1)
Note over Network,Infrastructure: Resource change events
Network->>Controller: change event (ClusterNetwork)
Infrastructure->>Controller: change event (APIServerInternalURL)
Controller->>Reconciler: Enqueue reconcile request
Reconciler->>Network: Read ClusterNetwork CIDRs
Reconciler->>Infrastructure: Read APIServerInternalURL
Reconciler->>Proxy: Update Status.NoProxy (CIDRs + hostname)
Proxy->>Reconciler: Status updated
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.12.2)level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: inconsistent vendoring in :\n\tgithub.com/Masterminds/semver@v1.5.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/Masterminds/sprig/v3@v3.2.3: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/containernetworking/cni@v0.8.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/ghodss/yaml@v1.0.1-0.20190212211648-25d852aebe32: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/go-bindata/go-bindata@v3.1.2+incompatible: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/onsi/gomega@v1.39.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tgithub.com/ope ... [truncated 17357 characters] ... red in go.mod, but not marked as explicit in vendor/modules.txt\n\tk8s.io/gengo/v2@v2.0.0-20251215205346-5ee0d033ba5b: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tk8s.io/kms@v0.35.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tk8s.io/kube-aggregator@v0.35.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tsigs.k8s.io/randfill@v1.0.0: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\tsigs.k8s.io/structured-merge-diff/v6@v6.3.2: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt\n\n\tTo ignore the vendor directory, use -mod=readonly or -mod=mod.\n\tTo sync the vendor directory, run:\n\t\tgo mod vendor\n" Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jluhrsen The full list of commands accepted by this bot can be found 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.
🧹 Nitpick comments (1)
pkg/controller/proxyconfig/controller_test.go (1)
220-228: Also assert that the old API hostname is removed.Right now this test only proves the new hostname was added. It would still pass if reconciliation appended the new host without dropping the stale one.
Suggested assertion
if !strings.Contains(proxy.Status.NoProxy, updatedAPIServer) { t.Errorf("Expected proxy.Status.NoProxy to contain updated API server %s, got: %s", updatedAPIServer, proxy.Status.NoProxy) } + if strings.Contains(proxy.Status.NoProxy, initialAPIServer) { + t.Errorf("proxy.Status.NoProxy still contains old API server %s, got: %s", + initialAPIServer, proxy.Status.NoProxy) + }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/controller/proxyconfig/controller_test.go` around lines 220 - 228, The test currently only asserts that proxy.Status.NoProxy contains updatedAPIServer; also assert that the previous API hostname is removed by checking that strings.Contains(proxy.Status.NoProxy, oldAPIServer) is false (use whatever variable name holds the pre-update hostname in this test), i.e., add an assertion after fetching proxy that proxy.Status.NoProxy does NOT contain the old API hostname to ensure reconciliation replaced rather than appended the host.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pkg/controller/proxyconfig/controller_test.go`:
- Around line 220-228: The test currently only asserts that proxy.Status.NoProxy
contains updatedAPIServer; also assert that the previous API hostname is removed
by checking that strings.Contains(proxy.Status.NoProxy, oldAPIServer) is false
(use whatever variable name holds the pre-update hostname in this test), i.e.,
add an assertion after fetching proxy that proxy.Status.NoProxy does NOT contain
the old API hostname to ensure reconciliation replaced rather than appended the
host.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 41e9f990-8f6b-40f0-b896-52eb993948a5
📒 Files selected for processing (3)
pkg/client/fake/fake_client.gopkg/controller/proxyconfig/controller.gopkg/controller/proxyconfig/controller_test.go
|
/retest |
|
/jira refresh |
|
@jluhrsen: This pull request references Jira Issue OCPBUGS-81741, which is valid. 3 validation(s) were run on this bug
DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
16d068b to
74e43ba
Compare
|
@danwinship @tssurya @kyrtapz @pliurh looking for someone to check on this. it's been sitting idle on my open bug list for a while now. haven't really followed up to find a reviewer yet. I've verified the fix manually and passed this through coderabbit review (locally). should be good for a human to look now. |
|
/retest |
1 similar comment
|
/retest |
|
/test 4.22-upgrade-from-stable-4.21-e2e-azure-ovn-upgrade |
danwinship
left a comment
There was a problem hiding this comment.
(oops, I reviewed this the other day but I guess I forgot to hit "submit")
| } | ||
|
|
||
| // Watch for changes to the network resource. | ||
| err = c.Watch(source.Kind[crclient.Object](mgr.GetCache(), &configv1.Network{}, &handler.EnqueueRequestForObject{})) |
There was a problem hiding this comment.
This should require a change to Reconcile() too shouldn't it? (It checks what kind of object it's reconciling.)
Assuming that's correct, that means this patch doesn't actually work at all, which makes me feel like it probably ought to have had a corresponding e2e test?
There was a problem hiding this comment.
Thanks @danwinship . I tested this fix with a live cluster so I am pretty confident in the change, but obviously don't know this code base like you do.
But, I think it works because Reconcile() is interested in the "Name" which I guess always will be "cluster" for these.
I think an e2e might be complicated, but if you need one figured out to validate this even further, I try to figure it out.
There was a problem hiding this comment.
huh... you should fix Reconcile so that the switch does something that actually looks like it should work, rather than than something that just coincidentally happens to work. Possibly just split out the "configmap" and "not a configmap" cases.
There was a problem hiding this comment.
ok, I think I see what you mean. I gave it another try to hopefully make it a little more clear
74e43ba to
67eeb38
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/controller/proxyconfig/controller.go`:
- Line 117: The log call using log.Println in the proxyconfig controller (the
line that currently reads "Ignoring unknown cluster-scoped object,
reconciliation will be skipped", "request", request) should be changed to use
log.Printf with a format specifier so the request is rendered correctly; update
the logging in the reconcile/controller function where that log.Println appears
(reference the log.Println call) to something like log.Printf("Ignoring unknown
cluster-scoped object, reconciliation will be skipped: request=%v", request) so
the request value is formatted into the message.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: f179ee0c-097c-4ca1-b085-57f324f1b0c9
📒 Files selected for processing (3)
pkg/client/fake/fake_client.gopkg/controller/proxyconfig/controller.gopkg/controller/proxyconfig/controller_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- pkg/client/fake/fake_client.go
- pkg/controller/proxyconfig/controller_test.go
67eeb38 to
fc3adac
Compare
The proxyconfig controller reads Network.Status.ClusterNetwork and Infrastructure.Status to compute Proxy.Status.NoProxy, but only watched Proxy and ConfigMaps. Network or Infrastructure changes would not trigger reconciliation, leaving proxy status stale. Add watches for Network and Infrastructure resources to ensure reconciliation occurs when these resources change. Also add Proxy status subresource support to fake client and unit tests covering reconciliation logic. Signed-off-by: Jamo Luhrsen <jluhrsen@gmail.com> Co-authored-by: Claude Code <noreply@anthropic.com)
fc3adac to
9818f9c
Compare
|
/retest |
|
@jluhrsen: 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. |
The proxyconfig controller reads Network.Status.ClusterNetwork and Infrastructure.Status to compute Proxy.Status.NoProxy, but only watched Proxy and ConfigMaps. Network or Infrastructure changes would not trigger reconciliation, leaving proxy status stale.
Add watches for Network and Infrastructure resources to ensure reconciliation occurs when these resources change.
Also add Proxy status subresource support to fake client and unit tests covering reconciliation logic.
Co-authored-by: Claude Code <noreply@anthropic.com)
Summary by CodeRabbit
Tests
Improvements
Chores