OCPBUGS-98724: egress-router: Propagate macvlan master and mode to NAD config#3057
OCPBUGS-98724: egress-router: Propagate macvlan master and mode to NAD config#3057Ultimate-etamitlU wants to merge 1 commit into
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@Ultimate-etamitlU: This pull request references Jira Issue OCPBUGS-98724, 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. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
Summary by CodeRabbit
WalkthroughThe egress-router controller passes explicit MACVLAN mode and master values to the NAD template. The template renders CNI interface configuration with conditional master handling and lowercase mode output. Tests validate the rendered configuration and destination JSON. ChangesMACVLAN NAD rendering
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (3 errors, 1 warning)
✅ Passed checks (20 passed)
✨ 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@v1.3.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 17377 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" Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ultimate-etamitlU 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 |
5d63b0e to
44a14ff
Compare
|
Hi @Ultimate-etamitlU. Thanks for your PR. I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/controller/egress_router/egress_router_controller_test.go (1)
56-77: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winReplace custom
unstructuredNestedStringwithunstructured.NestedString.This function reimplements
unstructured.NestedStringfromk8s.io/apimachinery/pkg/apis/meta/v1/unstructured. Prefer using the well-known library function to reduce boilerplate and align with standard Kubernetes ecosystem patterns.♻️ Proposed refactor
First, add the import for the
unstructuredpackage at the top of the file:import ( // ... "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" )Then, remove this custom function entirely and update its call site on line 41:
- configStr, found, err := unstructuredNestedString(obj.Object, "spec", "config") + configStr, found, err := unstructured.NestedString(obj.Object, "spec", "config")🤖 Prompt for 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. In `@pkg/controller/egress_router/egress_router_controller_test.go` around lines 56 - 77, Remove the custom unstructuredNestedString helper and import k8s.io/apimachinery/pkg/apis/meta/v1/unstructured. Update its call site to use unstructured.NestedString directly, preserving the existing nested-field lookup behavior.
🤖 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.
Nitpick comments:
In `@pkg/controller/egress_router/egress_router_controller_test.go`:
- Around line 56-77: Remove the custom unstructuredNestedString helper and
import k8s.io/apimachinery/pkg/apis/meta/v1/unstructured. Update its call site
to use unstructured.NestedString directly, preserving the existing nested-field
lookup behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: c6496fbe-1351-4b39-bcd9-66a25cc52aae
📒 Files selected for processing (3)
bindata/egress-router/000-nad.yamlpkg/controller/egress_router/egress_router_controller.gopkg/controller/egress_router/egress_router_controller_test.go
|
@coderabbitai review |
✅ Action performedReview finished.
|
The EgressRouter controller set network_interfaces render data but the NAD template never referenced it, so the egress-router-cni plugin always auto-detected master as the default route interface (br-ex) and defaulted mode to bridge, ignoring user-specified values. Add interfaceType and interfaceArgs fields to the NAD template and wire MacvlanMaster/MacvlanMode through the controller render data. When master is not specified, the CNI plugin continues to auto-detect. Unit tests added for master propagation, master omission when empty, mode lowercasing for all macvlan modes, and AllowedDestinations JSON generation. Signed-off-by: Parikshit Khedekar <pkhedeka@redhat.com>
e5fd90c to
b91136e
Compare
Why
The EgressRouter controller sets
network_interfacesrender data but the NAD template never references it. The egress-router-cni plugin sees nointerfaceArgsin the CNI config, so it auto-detects master as the default route interface (br-exon OVN-Kubernetes nodes) and defaults mode tobridge— ignoring user-specifiedspec.networkInterface.macvlan.masterandspec.networkInterface.macvlan.mode.What
network_interfacesrender data with explicitMacvlanMasterandMacvlanModevalues in the controllerinterfaceTypeandinterfaceArgsfields to the NAD template, with conditionalmasterinclusionBridge→ CNI:bridge)masteris not specified in the CR, behavior is unchanged — the CNI plugin continues to auto-detectTesting / How to verify it
Automated
make test-unitpasses locallyci/prow/e2e-gcp-ovn,ci/prow/e2e-aws-ovn-serial-*cover EgressRouter functionalityManual verification
masterset to a VLAN subinterface — verify NAD contains correctinterfaceArgs.mastermaster— verify CNI plugin still auto-detects (backward compat)User impact
EgressRouter CRs with
spec.networkInterface.macvlan.masterset will now correctly use the specified parent interface instead of silently falling back tobr-ex.Upgrade / Rollback
interfaceArgsfields on next reconciliation. CRs without explicitmasterare unaffected.interfaceArgs; CNI plugin auto-detects as before.