canonical / canonical/cloud-init

get_interfaces_by_mac_on_linux: RuntimeError: duplicate mac found (driver: mlx5_core)

Open
#5,794 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Bug report
We are creating an instance with multiple network interfaces with the same MAC address on purpose because they are part of the same SR-IOV bond, but cloud-init code throws an exception.

## Steps to reproduce the problem
Create an instance connected with 2 or more Mellanox CX5 or CX6 SR-IOV virtual functions with the same MAC address. The driver is mlx5_core.

## Environment details
- Cloud-init version: 23.4-7.0.1.el9_4.3
- Operating System Distribution: Oracle Linux 9.4
- Cloud provider, platform or installer type: Oracle Cloud

## cloud-init logs
```
[ 27.864643] cloud-init[1535]: Cloud-init v. 23.4-7.0.1.el9_4.3 running 'init-local' at Fri, 04 Oct 2024 21:57:35 +0000. Up 27.84 seconds.
[ 27.932817] cloud-init[1535]: 2024-10-04 21:57:35,819 - util.py[WARNING]: Failed to parse IMDS network configuration!
[ 27.937519] cloud-init[1535]: 2024-10-04 21:57:35,824 - util.py[WARNING]: failed stage init-local
[ 27.941049] cloud-init[1535]: failed run of stage init-local
[ 27.941601] cloud-init[1535]: ------------------------------------------------------------
[ 27.943182] cloud-init[1535]: Traceback (most recent call last):
[ 27.943841] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/cmd/main.py", line 781, in status_wrapper
[ 27.945303] cloud-init[1535]: ret = functor(name, args)
[ 27.948436] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/cmd/main.py", line 442, in main_init
[ 27.949544] cloud-init[1535]: init.apply_network_config(bring_up=bring_up_interfaces)
[ 27.950535] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/stages.py", line 997, in apply_network_config
[ 27.951721] cloud-init[1535]: netcfg, src = self._find_networking_config()
[ 27.952608] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/stages.py", line 936, in _find_networking_config
[ 27.954105] cloud-init[1535]: if self.datasource and hasattr(self.datasource, "network_config"):
[ 27.955260] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceOracle.py", line 273, in network_config
[ 27.956327] cloud-init[1535]: _ensure_netfailover_safe(self._network_config)
[ 27.956994] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceOracle.py", line 96, in _ensure_netfailover_safe
[ 27.958135] cloud-init[1535]: mac_to_name = get_interfaces_by_mac()
[ 27.958751] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/net/__init__.py", line 897, in get_interfaces_by_mac
[ 27.959788] cloud-init[1535]: return get_interfaces_by_mac_on_linux()
[ 27.960406] cloud-init[1535]: File "/usr/lib/python3.9/site-packages/cloudinit/net/__init__.py", line 996, in get_interfaces_by_mac_on_linux
[ 27.961503] cloud-init[1535]: raise RuntimeError(msg)
[ 27.962022] cloud-init[1535]: RuntimeError: duplicate mac found! both 'ens6' and 'ens5' have mac '00:13:97:6f:3d:9f'.
[ 27.962936] cloud-init[1535]: ------------------------------------------------------------
```

We want those ens5 and ens6 Mellanox SR-IOV / virtual function interfaces to be ignored, as a custom script will configure bonding, what would be the best solution for this within the cloud-init framework?

The workaround today is to only attach those SR-IOV interfaces after the first boot, but this problem occurs if attached at first boot.

Also, I couldn't run collect-logs because I couldn't log in to the instance since the cloud-init process was stopped by this problem.

Thank you,
Jeremy

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.