wrong HWADDR on interface when ethernet_mac_address is given on the bond
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Expired
|
Undecided
|
Unassigned |
Bug Description
creating a configuration for an active-backup bond:
```
cloud-init devel net-convert -p network_data.json -k network_data.json \
-d /tmp -D rhel -O sysconfig \
-m eno50,b2:
```
with cloud-init (cloud-
assuming there is a ethernet_
```
{
"id": "bond0",
"type": "bond",
"
"bond_mode": "active-backup"
...
```
we see cloud-init creates a file ifcfg-eno53 wrongly containing a HWADDR with the address of the bond.
For a bond, we expect both interfaces to display the same mac when running ip link (default behavior with fail_over_mac=0 bonding module parameter). However, the HWADDR in the ifcfg file must retain the original mac address of the interface, or the interface is not configured correctly. Practically, it is never configured as slave.
Workaround seems to just remove the "ethernet_
I would expect the ifcfg-eno53 mac address to not be impacted by the presence of ethernet_
Hi frigo, thanks for the bug report! I've reproduced the issue locally, and done some initial investigation.
The OpenStack network_data.json parsing code itself is not responsible for this: if I instrument it to emit the config it generates, I see:
[{'mac_address': 'b2:35: 4a:42:42: ed', 4a:42:42: ee', interfaces' : ['eno50', 'eno53'], 4a:42:42: ed'},
'ipv4' : True,
'netmask' : '255.255.254.0',
'routes' : [{'gateway': '2.30.162.1',
' netmask' : '0.0.0.0',
' network' : '0.0.0.0'}],
'type' : 'static'}], 4a:42:42: ed',
'mtu': 1500,
'name': 'eno50',
'subnets': [],
'type': 'physical'},
{'mac_address': 'b2:35:
'mtu': 1500,
'name': 'eno53',
'subnets': [],
'type': 'physical'},
{'bond_
'name': 'bond0',
'params': {'bond_mode': 'active-backup', 'mac_address': 'b2:35:
'subnets': [{'address': '2.30.162.119',
'type': 'bond'},
{'mac_address': 'b2:35:
'name': 'bond0.591',
'subnets': [],
'type': 'vlan',
'vlan_id': 591,
'vlan_link': 'bond0'},
{'address': '2.23.186.183', 'type': 'nameserver'},
{'address': '2.23.186.184', 'type': 'nameserver'}]
As we can see, eno53 correctly has its :ee MAC address.
Digging in further, I believe the issue is in the network_state code (and so, I suspect, does not only affect RHEL/sysconfig). Specifically, https:/ /github. com/canonical/ cloud-init/ blob/master/ cloudinit/ net/network_ state.py# L456-L458 is doing (earlier line included for context):
for ifname in command. get('bond_ interfaces' ): get('params' ).items( ):
bond_ if.update( {param: val})
...
# copy in bond config into slave
for param, val in command.
This iterates over each of the ifnames in bond_interfaces, and sets every (param, val) in `command[ "params" ]`; in a debugger, I can see that `command["params"]` is:
ipdb> command. get('params' ) 4a:42:42: ed', 'bond_mode': 'active-backup'}
{'mac_address': 'b2:35:
As a result, every bond member will have the bond's configured MAC address set on them. (In the given configuration, eno50's MAC address is also modified, but as it already has the same MAC address as the bond, it has no effect.)