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 setting the --encap-ip argument when OVN_ENCAP_IP is provided.
    • Updated node startup to incorporate the resulting encapsulation IP flag when launching ovnkube, ensuring consistent encapsulation address selection with environment variable overrides.

@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 includes that flag when launching ovnkube.

Changes

Encapsulation IP Flag Wiring

Layer / File(s) Summary
Helper and startup wiring
bindata/network/ovn-kubernetes/common/008-script-lib.yaml
set-encap-ip-flag() sets ovn_encap_ip_flag from OVN_ENCAP_IP, and start-ovnkube-node() calls it before passing the flag to ovnkube.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 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.
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 The PR only changes a shell script library; no Ginkgo test declarations or titles are added or modified, so there are no unstable test names.
Test Structure And Quality ✅ Passed No Ginkgo test code was added or modified; the only test change is deletion of a plain Go test file, so this check is not applicable.
Microshift Test Compatibility ✅ Passed Only a shell-script helper in 008-script-lib.yaml changed; no new Ginkgo test declarations or MicroShift-unsafe OpenShift APIs/features were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the change only updates ovnkube shell-script helpers, and the modified file contains no It/Describe/Context/When blocks.
Topology-Aware Scheduling Compatibility ✅ Passed Only ovnkube node shell startup flag handling changed; no replicas, affinity, selectors, spread constraints, or topology checks were added.
Ote Binary Stdout Contract ✅ Passed PASS: The PR only edits a shell-script ConfigMap; no Go main/init/TestMain/suite code or stdout redirection changes were introduced.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR changes script bundle and unit tests only; no new Ginkgo e2e tests or internet-facing assumptions were added.
No-Weak-Crypto ✅ Passed The PR only adds ovnkube node flag plumbing; I found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB or secret-comparison code in the touched file or diff.
Container-Privileges ✅ Passed The PR only changes ovnkube startup shell logic in 008-script-lib.yaml; no K8s/container privilege fields were added or modified.
No-Sensitive-Data-In-Logs ✅ Passed The only new log prints OVN_ENCAP_IP (an encap IP), and no passwords, tokens, PII, hostnames, or customer data are logged.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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 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
@openshift-ci

openshift-ci Bot commented Jun 29, 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-metal-ipi-ovn-ipv6-ipsec f596db7 link true /test e2e-metal-ipi-ovn-ipv6-ipsec
ci/prow/e2e-metal-ipi-ovn-dualstack-bgp f596db7 link true /test e2e-metal-ipi-ovn-dualstack-bgp
ci/prow/5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-upgrade f596db7 link false /test 5.0-upgrade-from-stable-4.22-e2e-gcp-ovn-upgrade
ci/prow/e2e-ovn-ipsec-step-registry f596db7 link true /test e2e-ovn-ipsec-step-registry
ci/prow/e2e-metal-ipi-ovn-dualstack-bgp-local-gw f596db7 link true /test e2e-metal-ipi-ovn-dualstack-bgp-local-gw
ci/prow/e2e-aws-ovn-upgrade f596db7 link true /test e2e-aws-ovn-upgrade
ci/prow/5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade f596db7 link false /test 5.0-upgrade-from-stable-4.22-e2e-aws-ovn-upgrade
ci/prow/e2e-aws-ovn-hypershift-conformance f596db7 link true /test e2e-aws-ovn-hypershift-conformance
ci/prow/e2e-aws-ovn-fdp-qe f596db7 link true /test e2e-aws-ovn-fdp-qe

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants