Skip to content

fix the external net creation failure#40

Merged
masco merged 1 commit into
mainfrom
fix-ext-net
Jun 1, 2026
Merged

fix the external net creation failure#40
masco merged 1 commit into
mainfrom
fix-ext-net

Conversation

@masco
Copy link
Copy Markdown
Member

@masco masco commented Jun 1, 2026

if the interface is already created with same ip it failing on the subsequent runs. now adding a check before creating the interface

Summary by CodeRabbit

  • Bug Fixes
    • Improved VLAN interface configuration reliability by adding existence checks before creating interfaces and assigning IP addresses. The setup process is now idempotent and can be safely re-run without errors.

if the interface is already created with same ip it failing
on the subsequent runs. now adding a check before creating the interface
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

The Create vlan interface on external interface task in the Ansible playbook is made idempotent by adding conditional checks: the VLAN link creation now verifies existence before adding it, and IP address assignment checks if the gateway address is already present on the interface before configuring it.

Changes

VLAN Interface Idempotency

Layer / File(s) Summary
Idempotent VLAN interface and IP assignment
ansible/roles/post/tasks/main.yml
The shell commands in the VLAN interface creation task are updated to conditionally create the link if it does not exist and conditionally assign the IP address if it is not already configured.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • redhat-performance/JetBrew#36: Adds VLAN interface and network setup tasks to the same file and plays an earlier role in creating the external interface gateway configuration.

Poem

A rabbit hops through idempotent lands,
Where interfaces don't double-build their hands,
Check before you create, that's the way,
No duplicate VLANs shall see the day! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a failure in external network creation by making VLAN interface creation idempotent through existence checks.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ext-net

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

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

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.

🧹 Nitpick comments (1)
ansible/roles/post/tasks/main.yml (1)

5-9: ⚡ Quick win

Consider adding error handling for robustness.

The shell block lacks explicit error handling (set -e or set -o pipefail). While Ansible checks the final exit code, intermediate command failures might be missed. Adding error handling would ensure any unexpected failures are caught immediately.

🛡️ Proposed fix to add error handling
  shell: |
+   set -e
    ip link show {{ vlan_interface }} > /dev/null 2>&1 || ip link add link {{ iface_2 }} name {{ vlan_interface }} type vlan id {{ external_network_vlan_id }}
    ip link set dev {{ iface_2 }} up
    ip link set dev {{ vlan_interface }} up
    ip addr show dev {{ vlan_interface }} | grep -q "{{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }}" || ip a a {{ external_net_gateway }}/{{ external_net_cidr.split('/')[1] }} dev {{ vlan_interface }}
🤖 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 `@ansible/roles/post/tasks/main.yml` around lines 5 - 9, The shell task that
manipulates vlan_interface and iface_2 (creating VLAN with
external_network_vlan_id and assigning external_net_gateway/external_net_cidr)
should fail fast on any intermediate command failure; update the shell block to
enable strict error handling (e.g., set -euo pipefail or set -o errexit -o
nounset -o pipefail) at the start of the heredoc so any command failure aborts
the task, and ensure any intentionally tolerated commands are explicitly handled
(using || true or conditional checks) to avoid masking errors.
🤖 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 `@ansible/roles/post/tasks/main.yml`:
- Around line 5-9: The shell task that manipulates vlan_interface and iface_2
(creating VLAN with external_network_vlan_id and assigning
external_net_gateway/external_net_cidr) should fail fast on any intermediate
command failure; update the shell block to enable strict error handling (e.g.,
set -euo pipefail or set -o errexit -o nounset -o pipefail) at the start of the
heredoc so any command failure aborts the task, and ensure any intentionally
tolerated commands are explicitly handled (using || true or conditional checks)
to avoid masking errors.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a2d14ab3-b056-40b0-97b3-a20567dab061

📥 Commits

Reviewing files that changed from the base of the PR and between 99a62c6 and a5654e1.

📒 Files selected for processing (1)
  • ansible/roles/post/tasks/main.yml

@masco masco merged commit e994173 into main Jun 1, 2026
2 checks passed
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.

1 participant