Skip to content

Commit b5f7545

Browse files
fultonjopenshift-merge-bot[bot]
authored andcommitted
[libvirt_manager] generate unique MAC per interface in generate_macs
Previously, a single MAC address (_fixed_mac) was generated once per VM and assigned to all its network interfaces. For OCP master VMs with multiple networks (e.g. ocppr, ocpbm, osp_trunk, osp_trunk), all interfaces shared the same MAC. This caused the networking_mapper to always resolve to the first interface (enp5s0, on the ocppr bridge) when looking up any network by MAC, since all MACs matched equally. The incorrect interface name then flowed into ci_gen_kustomize_values, setting enp5s0 as the macvlan master in the ctlplane NetworkAttachmentDefinition. Bootstrap pods sent ARP on the wrong bridge and never reached compute nodes, causing wait_for_connection to time out. Fix: generate a unique MAC per (VM, network-index) pair by incorporating loop.index0 into the seed, ensuring each interface gets a distinct MAC. The networking_mapper can then correctly identify enp7s0 (on cifmw-osp_trunk) as the ctlplane interface. Fixes: OSPRH-28297 Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: John Fulton <fulton@redhat.com>
1 parent ef818ee commit b5f7545

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

roles/libvirt_manager/tasks/generate_macs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
vm: "{{ _vm.key }}"
1212
_vm_type: "{{ _vm.value }}"
1313
_mac_seed: "{{ '52:54:%02i' % vm_id }}"
14-
_fixed_mac: "{{ _mac_seed | community.general.random_mac }}"
1514
# We don't generate MAC for spineleafnets - if that one is set
1615
# we won't get "nets" entry. Just use an empty list in that case.
1716
_nets_list: >-
@@ -25,14 +24,15 @@
2524
{% set _macs = cifmw_libvirt_manager_mac_map[vm] -%}
2625
{% endif -%}
2726
{% for network in _nets_list -%}
27+
{% set _net_mac = ('52:54:%02i:%02i' % (vm_id, loop.index0)) | community.general.random_mac -%}
2828
{% if cifmw_libvirt_manager_mac_map |
2929
dict2items | selectattr('key', 'equalto', vm) |
3030
map(attribute='value') | first | default([]) |
3131
items2dict(key_name='network', value_name='mac') |
3232
dict2items | map(attribute='key') |
3333
select('equalto', network) | length == 0 -%}
3434
{% set _ = _macs.append({'network': network,
35-
'mac': _fixed_mac }) -%}
35+
'mac': _net_mac }) -%}
3636
{% endif -%}
3737
{% endfor -%}
3838
{% if _macs | length != 0 -%}

0 commit comments

Comments
 (0)