Skip to content

Resolve ovnkube node encap IP in startup script#2998

Draft
SchSeba wants to merge 1 commit intoopenshift:masterfrom
SchSeba:encap-ip-from-file-and-env
Draft

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

Conversation

@SchSeba
Copy link
Copy Markdown
Contributor

@SchSeba SchSeba commented May 7, 2026

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
    • Enhanced network configuration capabilities with automatic detection and selection of appropriate network interface addresses, supporting configuration files and environment variable overrides for flexible customization.

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.

Signed-off-by: Sebastian Sch <sebassch@gmail.com>
@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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 7, 2026

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
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Walkthrough

Two shell helper functions are added to resolve encapsulation IP: get-first-interface-address() extracts the first global IPv4/IPv6 address from a network interface, and set-encap-ip-flag() determines the --encap-ip argument from a config file or OVN_ENCAP_IP environment variable. The start-ovnkube-node() function integrates this by calling set-encap-ip-flag() and passing the result to ovnkube.

Changes

Encapsulation IP Resolution

Layer / File(s) Summary
Helper Functions
bindata/network/ovn-kubernetes/common/008-script-lib.yaml (lines 481–548)
get-first-interface-address() reads /proc/net/if_inet6 and /proc/net/arp to extract global IPv4/IPv6 addresses from a given interface. set-encap-ip-flag() resolves --encap-ip from /etc/ovnk/encap_interface (or /host/etc/ovnk/encap_interface), OVN_ENCAP_IP env var, or interface-based fallback.
Integration
bindata/network/ovn-kubernetes/common/008-script-lib.yaml (line 780)
start-ovnkube-node() invokes set-encap-ip-flag to compute the encapsulation IP and passes ${ovn_encap_ip_flag} to the ovnkube command.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and accurately summarizes the main change: dynamically resolving the ovnkube node encapsulation IP in the startup script based on interface availability and environment overrides.
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 custom check for stable Ginkgo test names is not applicable to this PR. The PR modifies only a shell script library (008-script-lib.yaml) containing utility functions, not Ginkgo tests or Go code.
Test Structure And Quality ✅ Passed Check not applicable. PR modifies only YAML and shell script files, not Ginkgo test code. No test files were modified.
Microshift Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. The changes are limited to shell script helper functions in a ConfigMap YAML file. The custom check for MicroShift test compatibility does not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies only shell script library code and contains no Ginkgo e2e tests. The SNO Test Compatibility check applies only to new e2e tests, which are not present here.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies a shell script library ConfigMap adding IP address resolution functions. No scheduling constraints, pod specs, affinity rules, node selectors, or topology-aware scheduling is introduced.
Ote Binary Stdout Contract ✅ Passed Custom check is not applicable. PR modifies shell script configuration for OVN-Kubernetes network operator, not OTE binary test infrastructure.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR only modifies a YAML manifest file with shell script code. It does not add any new Ginkgo e2e tests. The custom check targets Ginkgo e2e tests and is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 7, 2026

[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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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.

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

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant