Skip to content

Resolve ovnkube node encap IP in startup script#2998

Open
SchSeba wants to merge 1 commit into
openshift:masterfrom
SchSeba:encap-ip-from-file-and-env
Open

Resolve ovnkube node encap IP in startup script#2998
SchSeba wants to merge 1 commit into
openshift:masterfrom
SchSeba:encap-ip-from-file-and-env

Conversation

@SchSeba

@SchSeba SchSeba commented May 7, 2026

Copy link
Copy Markdown
Contributor

Teach the ovnkube node wrapper to derive --encap-ip from /etc/ovnk/encap_interface, including host-mounted lookups and dual-stack addresses, while allowing OVN_ENCAP_IP to override the resolved value for per-node configuration.

Summary by CodeRabbit

  • New Features

    • Improved network encapsulation configuration by automatically wiring OVN_ENCAP_IP into the ovnkube startup as --encap-ip=${OVN_ENCAP_IP}.
    • Updated node startup to incorporate this encapsulation IP flag during startup.
    • Ensured per-node environment overrides are supported via an optional ConfigMap volume mounted at /env.
  • Tests

    • Added rendering tests covering OVN_ENCAP_IP wiring and the env-overrides volume/ConfigMap behavior.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 7, 2026
@openshift-ci

openshift-ci Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Walkthrough

ovnkube startup now derives an encapsulation IP flag from OVN_ENCAP_IP and passes it into the node launch command, with rendering tests covering the env override wiring and optional /env volume.

Changes

Encapsulation IP startup wiring

Layer / File(s) Summary
Encap flag helper
bindata/network/ovn-kubernetes/common/008-script-lib.yaml
set-encap-ip-flag() initializes ovn_encap_ip_flag and sets it from OVN_ENCAP_IP when present.
Node startup command wiring
bindata/network/ovn-kubernetes/common/008-script-lib.yaml
start-ovnkube-node() calls the helper before launching ovnkube and adds ovn_encap_ip_flag to the command arguments.
Renderer coverage
pkg/network/ovn_kubernetes_test.go
Tests assert the rendered script includes OVN_ENCAP_IP flag wiring and that the optional env-overrides volume is mounted at /env.

Estimated code review effort: 2 (Simple) | ~10 minutes


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error The new helper logs OVN_ENCAP_IP verbatim (Using OVN_ENCAP_IP=...), which can expose node/internal IP details in logs. Remove or redact the value from the log (e.g. log only that an override is present) and avoid printing the raw encap IP.
✅ Passed checks (14 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: resolving ovnkube node encap IP during startup script execution.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed Added tests use static names; no Ginkgo titles or dynamic identifiers appear in the changed code.
Test Structure And Quality ✅ Passed Both new render tests stay single-purpose, use no cluster ops/timeouts, and match existing test patterns in this file.
Microshift Test Compatibility ✅ Passed The added tests are plain render/unit tests, not Ginkgo e2e tests, and they only inspect DaemonSet/script rendering without MicroShift-unsupported APIs or cluster assumptions.
Single Node Openshift (Sno) Test Compatibility ✅ Passed PASS: The added tests are plain render/unit tests, not Ginkgo e2e tests, and they contain no multi-node or HA assumptions.
Topology-Aware Scheduling Compatibility ✅ Passed PR only adds encap-ip env override wiring and test coverage; no node selectors, affinities, spread constraints, replica logic, or control-plane assumptions were added.
Ote Binary Stdout Contract ✅ Passed No added main/TestMain/init/suite code writes to stdout; the new Go changes are test bodies plus a package init with no printing.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The added tests are unit render tests, not Ginkgo e2e, and they contain no IPv4-only or external-connectivity assumptions.
No-Weak-Crypto ✅ Passed PASS: The changed files only add encap-IP env wiring and tests; no weak-crypto APIs, custom crypto, or secret/token comparisons appear in the diff.
Container-Privileges ✅ Passed No changed manifest introduces privileged, hostNetwork/PID/IPC, SYS_ADMIN, root, or allowPrivilegeEscalation settings; this PR only alters a script and tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 @coderabbitai help to get the list of available commands.

@openshift-ci

openshift-ci Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: SchSeba
Once this PR has been reviewed and has the lgtm label, please assign jcaamano for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 `@bindata/network/ovn-kubernetes/common/008-script-lib.yaml`:
- Around line 544-547: Normalize and trim whitespace from the OVN_ENCAP_IP
environment variable before constructing ovn_encap_ip_flag: create a trimmed
value (e.g., strip leading/trailing whitespace from OVN_ENCAP_IP), check that
the trimmed value is non-empty, then set
ovn_encap_ip_flag="--encap-ip=${TRIMMED_OVN_ENCAP_IP}" and log the trimmed
value; update uses of OVN_ENCAP_IP to reference the trimmed variable so
accidental surrounding whitespace won't produce an invalid or split --encap-ip
argument.
🪄 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: ed7676fc-f101-424f-bb21-db5380f271b0

📥 Commits

Reviewing files that changed from the base of the PR and between 5928824 and 55250eb.

📒 Files selected for processing (1)
  • bindata/network/ovn-kubernetes/common/008-script-lib.yaml

Comment on lines +544 to +547
if [[ -n "${OVN_ENCAP_IP}" ]]; then
log "encapip" "Using OVN_ENCAP_IP override ${OVN_ENCAP_IP}"
ovn_encap_ip_flag="--encap-ip=${OVN_ENCAP_IP}"
fi

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Normalize OVN_ENCAP_IP before building the flag.

At Line 544, OVN_ENCAP_IP is used verbatim. Accidental whitespace in env overrides can produce an invalid/split --encap-ip argument at runtime.

Suggested patch
-      if [[ -n "${OVN_ENCAP_IP}" ]]; then
-        log "encapip" "Using OVN_ENCAP_IP override ${OVN_ENCAP_IP}"
-        ovn_encap_ip_flag="--encap-ip=${OVN_ENCAP_IP}"
+      local encap_ip_override="${OVN_ENCAP_IP//[[:space:]]/}"
+      if [[ -n "${encap_ip_override}" ]]; then
+        log "encapip" "Using OVN_ENCAP_IP override ${encap_ip_override}"
+        ovn_encap_ip_flag="--encap-ip=${encap_ip_override}"
       fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [[ -n "${OVN_ENCAP_IP}" ]]; then
log "encapip" "Using OVN_ENCAP_IP override ${OVN_ENCAP_IP}"
ovn_encap_ip_flag="--encap-ip=${OVN_ENCAP_IP}"
fi
local encap_ip_override="${OVN_ENCAP_IP//[[:space:]]/}"
if [[ -n "${encap_ip_override}" ]]; then
log "encapip" "Using OVN_ENCAP_IP override ${encap_ip_override}"
ovn_encap_ip_flag="--encap-ip=${encap_ip_override}"
fi
🤖 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 `@bindata/network/ovn-kubernetes/common/008-script-lib.yaml` around lines 544 -
547, Normalize and trim whitespace from the OVN_ENCAP_IP environment variable
before constructing ovn_encap_ip_flag: create a trimmed value (e.g., strip
leading/trailing whitespace from OVN_ENCAP_IP), check that the trimmed value is
non-empty, then set ovn_encap_ip_flag="--encap-ip=${TRIMMED_OVN_ENCAP_IP}" and
log the trimmed value; update uses of OVN_ENCAP_IP to reference the trimmed
variable so accidental surrounding whitespace won't produce an invalid or split
--encap-ip argument.

@SchSeba SchSeba force-pushed the encap-ip-from-file-and-env branch from 55250eb to 71961a6 Compare June 24, 2026 13:28
@SchSeba SchSeba marked this pull request as ready for review June 24, 2026 13:30
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 24, 2026
@openshift-ci openshift-ci Bot requested review from arghosh93 and marty-power June 24, 2026 13:31
@tssurya

tssurya commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@SchSeba SchSeba force-pushed the encap-ip-from-file-and-env branch from 71961a6 to f596db7 Compare June 29, 2026 08:20
@SchSeba

SchSeba commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Hi @tssurya thanks for the comment!
done :)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 `@bindata/network/ovn-kubernetes/common/008-script-lib.yaml`:
- Around line 481-490: The set-encap-ip-flag helper currently only reads
OVN_ENCAP_IP, leaving ovn_encap_ip_flag empty when that env var is unset, so
update this function to also resolve the encap IP from the
/etc/ovnk/encap_interface fallback before start-ovnkube-node builds the ovnkube
command. Use the existing set-encap-ip-flag and start-ovnkube-node symbols to
wire in the file-based lookup, and ensure the fallback sets --encap-ip when the
mounted encap file is present.
🪄 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: eec6ff95-f2f2-4481-a5e7-0627390ea41b

📥 Commits

Reviewing files that changed from the base of the PR and between 71961a6 and f596db7.

📒 Files selected for processing (1)
  • bindata/network/ovn-kubernetes/common/008-script-lib.yaml

Comment thread bindata/network/ovn-kubernetes/common/008-script-lib.yaml

@tssurya tssurya 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.

  1. Please update the PR describe with the latest design details and remove references to our older approach or keep it for history but perhaps tell we didn't go with that approach.
  2. Attach the JIRA to the title
  3. Add a section on "How to test/verify this and how that was done" - we won't be able to set "verified" on this PR till that is done
  4. Add some unit tests to ensure the parsing works
  5. Address rabbit comments.

Main logic LGTM - looks simple

${gateway_mode_flags} \
${node_mgmt_port_netdev_flags} \
${ovnkube_node_mode} \
${ovn_encap_ip_flag} \

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.

is that it has to be a singe IP or comma of IPs is accepted for dualstack? what's the design for this config field upstream? I forget the details..

Teach the ovnkube node wrapper to derive --encap-ip from
the OVN_ENCAP_IP environment variable for per-node configuration.

The variable is expected to be set through the env-overrides ConfigMap
so that each node can receive its own encap IP. For example:

  apiVersion: v1
  kind: ConfigMap
  metadata:
    name: env-overrides
    namespace: openshift-ovn-kubernetes
  data:
    ocp-virt-ctlplane-0.lab: |
      OVN_ENCAP_IP=10.0.0.1
    ocp-virt-worker-0.lab: |
      OVN_ENCAP_IP=10.0.0.2
    ocp-virt-worker-1.lab: |
      OVN_ENCAP_IP=10.0.0.3
    ocp-virt-worker-2.lab: |
      OVN_ENCAP_IP=10.0.0.4

Signed-off-by: Sebastian Sch <sebassch@gmail.com>
@SchSeba SchSeba force-pushed the encap-ip-from-file-and-env branch from f596db7 to 08f19ed Compare July 9, 2026 06:59

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/network/ovn_kubernetes_test.go (1)

4408-4433: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicate test setup boilerplate.

The bootstrap/config setup (crd, config, bootstrapResult, featureGatesCNO, fakeClient, render call) is duplicated almost verbatim across both new tests. Consider extracting a shared helper (e.g., renderOVNKubernetesForEncapIPTest(t)) to reduce duplication and ease future maintenance.

♻️ Suggested helper extraction
+func renderOVNKubernetesWithDefaults(g *WithT) []*uns.Unstructured {
+	crd := OVNKubernetesConfig.DeepCopy()
+	config := &crd.Spec
+	fillDefaults(config, nil)
+
+	bootstrapResult := fakeBootstrapResult()
+	bootstrapResult.OVN = bootstrap.OVNBootstrapResult{
+		ControlPlaneReplicaCount: 3,
+		OVNKubernetesConfig: &bootstrap.OVNConfigBoostrapResult{
+			DpuHostModeLabel:          OVN_NODE_SELECTOR_DEFAULT_DPU_HOST,
+			DpuModeLabel:              OVN_NODE_SELECTOR_DEFAULT_DPU,
+			SmartNicModeLabel:         OVN_NODE_SELECTOR_DEFAULT_SMART_NIC,
+			MgmtPortResourceName:      "",
+			DpuNodeLeaseRenewInterval: DPU_NODE_LEASE_RENEW_INTERVAL_DEFAULT,
+			DpuNodeLeaseDuration:      DPU_NODE_LEASE_DURATION_DEFAULT,
+			HyperShiftConfig: &bootstrap.OVNHyperShiftBootstrapResult{
+				Enabled: false,
+			},
+		},
+	}
+	featureGatesCNO := getDefaultFeatureGates()
+	fakeClient := cnofake.NewFakeClient()
+
+	objs, _, err := renderOVNKubernetes(config, bootstrapResult, manifestDirOvn, fakeClient, featureGatesCNO)
+	g.Expect(err).NotTo(HaveOccurred())
+	return objs
+}

Also applies to: 4447-4473

🤖 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/network/ovn_kubernetes_test.go` around lines 4408 - 4433, The test setup
in TestRenderOVNKubernetes_EncapIPEnvOverrideWiring is duplicated across the new
encapsulation IP tests, including the crd/config
bootstrapResult/fakeClient/featureGatesCNO/renderOVNKubernetes flow. Extract the
repeated bootstrap and render setup into a shared helper such as
renderOVNKubernetesForEncapIPTest so both tests can call it and only customize
the scenario-specific assertions.
🤖 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/network/ovn_kubernetes_test.go`:
- Around line 4408-4433: The test setup in
TestRenderOVNKubernetes_EncapIPEnvOverrideWiring is duplicated across the new
encapsulation IP tests, including the crd/config
bootstrapResult/fakeClient/featureGatesCNO/renderOVNKubernetes flow. Extract the
repeated bootstrap and render setup into a shared helper such as
renderOVNKubernetesForEncapIPTest so both tests can call it and only customize
the scenario-specific assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 1177293e-03f9-4bec-97ee-dbf03fa611ce

📥 Commits

Reviewing files that changed from the base of the PR and between f596db7 and 08f19ed.

📒 Files selected for processing (2)
  • bindata/network/ovn-kubernetes/common/008-script-lib.yaml
  • pkg/network/ovn_kubernetes_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • bindata/network/ovn-kubernetes/common/008-script-lib.yaml

@tssurya

tssurya commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What about day2 changes? Are they supported? So once cluster comes up can users change this?
and is day0 supported - is it even possible to provide this at install time? what are the steps for user workflow - let's outline that in PR describe as well

@openshift-ci

openshift-ci Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@SchSeba: 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/e2e-ovn-ipsec-step-registry 08f19ed link true /test e2e-ovn-ipsec-step-registry
ci/prow/e2e-metal-ipi-ovn-ipv6-ipsec 08f19ed link true /test e2e-metal-ipi-ovn-ipv6-ipsec
ci/prow/5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-upgrade 08f19ed link false /test 5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-upgrade
ci/prow/e2e-metal-ipi-ovn-dualstack-bgp-local-gw 08f19ed link true /test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
ci/prow/5.0-upgrade-from-stable-4.22-e2e-azure-ovn-upgrade 08f19ed link false /test 5.0-upgrade-from-stable-4.22-e2e-azure-ovn-upgrade
ci/prow/e2e-azure-ovn-upgrade 08f19ed link true /test e2e-azure-ovn-upgrade
ci/prow/e2e-metal-ipi-ovn-ipv6 08f19ed link true /test e2e-metal-ipi-ovn-ipv6
ci/prow/e2e-aws-ovn-upgrade 08f19ed link true /test e2e-aws-ovn-upgrade
ci/prow/e2e-aws-ovn-upgrade-ipsec 08f19ed link true /test e2e-aws-ovn-upgrade-ipsec
ci/prow/5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade 08f19ed link false /test 5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade

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.

@zeeke zeeke 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.

only one minor comment on my side

// TestRenderOVNKubernetes_EncapIPEnvOverrideWiring verifies the rendered OVN
// script library sources per-node overrides and wires OVN_ENCAP_IP into the
// ovnkube-node command line.
func TestRenderOVNKubernetes_EncapIPEnvOverrideWiring(t *testing.T) {

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.

I'd drop this test, as it makes noise without giving too value

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants