Skip to content

Conversation

@manurodriguez
Copy link
Contributor

@manurodriguez manurodriguez commented Jun 13, 2025

SUMMARY

Add machine net and vips according to dual or single stack
- OCP >= 4.12 can use either IPv4/IPv6 dual or single stack
- anything before will default to IPv4
- use IPv4/IPv6 machineCIDR and VIPs accordingly

ISSUE TYPE

Enhanced Feature

Tests

TestBos2: virt

@manurodriguez manurodriguez requested a review from a team as a code owner June 13, 2025 10:28
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 13, 2025

📝 Walkthrough

Walkthrough

Adds release-version (4.12+) gating and per-IP-version conditional rendering to installer Jinja2 templates for machine/network/VIP fields, removes a default variable, and updates VIP validation conditions to match the new IPv4/IPv6/dual-stack logic.

Changes

Cohort / File(s) Change Summary
Installer templates
roles/installer/templates/install-config-virtualmedia.j2, roles/installer/templates/install-config.j2
Add release (4.12+) branching and per-IP-version conditionals: replace unconditional machineCIDR with machineNetwork containing IPv4/IPv6 CIDRs as appropriate; conditionally render clusterNetwork and serviceNetwork per IP version; change platform.baremetal VIP rendering to include apiVIPs/ingressVIPs for 4.12+ with IPv4/IPv6 gating and use ternary selection for older releases; preserve dnsVIP behavior for older releases.
Node prep defaults
roles/node_prep/defaults/main.yml
Remove default variable dualstack_vips.
Node prep validation tasks
roles/node_prep/tasks/10_validation.yml
Tighten API/Ingress VIP failure conditions to require dualstack_baremetal or ipv4_baremetal; relax IPv6 VIP validation for OCP ≥4.12 to run when IPv6 is enabled regardless of prior dual-stack VIP flag.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Suggested reviewers

  • tonyskapunk
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch test-ipv6-only-ipi

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@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

♻️ Duplicate comments (2)
roles/installer/templates/install-config-virtualmedia.j2 (2)

12-16: Same machineCIDR dual-stack issue as in bare-metal template

Apply the guard proposed for install-config.j2 to avoid conflicting machineCIDR + machineNetwork declarations.


53-65: Mirror the “safe-default” tweaks for VIP conditionals

The undefined-flag risk and the corresponding |default(false)|bool fix apply here too.

Also applies to: 67-68

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d7e16d and 172ea18.

📒 Files selected for processing (2)
  • roles/installer/templates/install-config-virtualmedia.j2 (2 hunks)
  • roles/installer/templates/install-config.j2 (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Sanity Check (stable-2.9)
  • GitHub Check: Ansible-lint Check
  • GitHub Check: Sanity Check (stable-2.18)
🔇 Additional comments (1)
roles/installer/templates/install-config.j2 (1)

53-65: Harden VIP conditional blocks against missing flag variables

Several tests (ipv4_baremetal|bool, ipv6_enabled|bool) assume the flag is always defined. If a higher-level playbook omits one of them, the template will raise an UndefinedError and abort the run.

Add safe defaults when casting to bool:

-{% if ipv4_baremetal|bool and apivip is defined and apivip|ipv4 %}
+{% if (ipv4_baremetal|default(false)|bool) and apivip is defined and apivip|ipv4 %}

-{% if ipv6_enabled|bool and apivip6 is defined and apivip6|ipv6 %}
+{% if (ipv6_enabled|default(false)|bool) and apivip6 is defined and apivip6|ipv6 %}

-{% if ipv4_baremetal|bool and ingressvip is defined and ingressvip|ipv4 %}
+{% if (ipv4_baremetal|default(false)|bool) and ingressvip is defined and ingressvip|ipv4 %}

-{% if ipv6_enabled|bool and ingressvip6 is defined and ingressvip6|ipv6 %}
+{% if (ipv6_enabled|default(false)|bool) and ingressvip6 is defined and ingressvip6|ipv6 %}

-    apiVIP: {{ (ipv4_baremetal|bool) | ternary(apivip, apivip6) }}
-    ingressVIP: {{ (ipv4_baremetal|bool) | ternary(ingressvip, ingressvip6) }}
+    apiVIP: {{ (ipv4_baremetal|default(false)|bool) | ternary(apivip, apivip6) }}
+    ingressVIP: {{ (ipv4_baremetal|default(false)|bool) | ternary(ingressvip, ingressvip6) }}

This small change makes the template resilient to callers that provide only one of the flags.

Also applies to: 67-68

@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Jun 13, 2025

@manurodriguez manurodriguez changed the title [installer ipi] use IPv6 machineCIDR and VIPs in singlestack ipv6 [ipi] add machine net and vips according to dual or single stack Jun 15, 2025
@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Jun 15, 2025

@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Jun 15, 2025

@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Jun 15, 2025

@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Jun 15, 2025

@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Jun 15, 2025

no_proxy_list: ""
http_proxy: ""
https_proxy: ""
ipv4_baremetal: false
Copy link
Contributor

Choose a reason for hiding this comment

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

Should ipv6_enabled have a default as ipv4_baremetal? I think it's needed to avoid breaking backward compatibility

@dcibot
Copy link
Collaborator

dcibot commented Jun 29, 2025

@tonyskapunk
Copy link
Contributor

@manurodriguez could you rebase this one?

- OCP >= 4.12 can use either IPv4/IPv6 dual or single stack
- anything before will default to IPv4
- use IPv4/IPv6 machineCIDR and VIPs accordingly
@manurodriguez
Copy link
Contributor Author

@manurodriguez could you rebase this one?

done, my bad, I'm resuming testing now

@softwarefactory-project-zuul
Copy link

Copy link
Contributor

@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

♻️ Duplicate comments (1)
roles/installer/templates/install-config.j2 (1)

69-70: Potential undefined VIP selection in fallback logic

Same issue as in the virtualmedia template - the ternary operators could select undefined values if neither VIP is properly defined.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 984f439 and f53d409.

📒 Files selected for processing (4)
  • roles/installer/templates/install-config-virtualmedia.j2 (2 hunks)
  • roles/installer/templates/install-config.j2 (2 hunks)
  • roles/node_prep/defaults/main.yml (0 hunks)
  • roles/node_prep/tasks/10_validation.yml (1 hunks)
💤 Files with no reviewable changes (1)
  • roles/node_prep/defaults/main.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • roles/node_prep/tasks/10_validation.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Sanity Check (stable-2.18)
  • GitHub Check: Sanity Check (stable-2.9)
  • GitHub Check: Ansible-lint Check
🔇 Additional comments (1)
roles/installer/templates/install-config-virtualmedia.j2 (1)

69-70: Please verify VIP validation for API and Ingress

I didn’t find any “required”, “assert” or “fail” checks for apivip/apivip6 or ingressvip/ingressvip6 in the roles, so the fallback ternaries may still produce undefined. Ensure that at least one of each pair is always defined—either by adding an Ansible assert/fail task or by upstream variable validation.

• File: roles/installer/templates/install-config-virtualmedia.j2
Lines 69–70

    apiVIP: {{ (apivip is defined and apivip|ipv4) | ternary(apivip, apivip6) }}
    ingressVIP: {{ (ingressvip is defined and ingressvip|ipv4) | ternary(ingressvip, ingressvip6) }}

Please confirm that you have validation in place or introduce one to prevent both values being undefined.

Comment on lines +22 to +23
machineCIDR: {{ extcidrnet }}
{% endif %}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Missing IPv6 support for pre-4.12 versions

For OpenShift versions < 4.12, the template always sets machineCIDR to extcidrnet (IPv4). This doesn't handle IPv6-only deployments on older versions. Consider adding conditional logic similar to what was previously suggested.

 {% else %}
+{% if ipv6_enabled|bool and not (dualstack_baremetal|bool or ipv4_baremetal|bool) %}
+  machineCIDR: {{ extcidrnet6 }}
+{% else %}
   machineCIDR: {{ extcidrnet }}
+{% endif %}
 {% endif %}
📝 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
machineCIDR: {{ extcidrnet }}
{% endif %}
{% else %}
- machineCIDR: {{ extcidrnet }}
+ {% if ipv6_enabled|bool and not (dualstack_baremetal|bool or ipv4_baremetal|bool) %}
+ machineCIDR: {{ extcidrnet6 }}
+ {% else %}
+ machineCIDR: {{ extcidrnet }}
+ {% endif %}
{% endif %}
🤖 Prompt for AI Agents
In roles/installer/templates/install-config.j2 around lines 22-23, the template
unconditionally sets machineCIDR to the IPv4 extcidrnet which breaks IPv6-only
pre-4.12 installs; modify the template to add a conditional branch for OpenShift
versions < 4.12 that uses the IPv6 CIDR variable when the cluster/network is
IPv6-only (e.g., check a provided ip_version or is_ipv6_only flag or the
existence of an extcidrnet_v6 variable) and fall back to extcidrnet for IPv4;
ensure the condition mirrors the earlier suggested logic so machineCIDR is set
to the IPv6 CIDR for IPv6-only clusters on older versions and to the IPv4
extcidrnet otherwise.

@dcibot
Copy link
Collaborator

dcibot commented Aug 11, 2025

@dcibot
Copy link
Collaborator

dcibot commented Aug 12, 2025

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Stale label Sep 11, 2025
@github-actions github-actions bot closed this Sep 18, 2025
@manurodriguez manurodriguez reopened this Sep 18, 2025
@manurodriguez manurodriguez added enhancement New feature or request and removed Stale labels Sep 18, 2025
@softwarefactory-project-zuul
Copy link

@dcibot
Copy link
Collaborator

dcibot commented Sep 18, 2025

@github-actions
Copy link

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants