You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PLM: Ubuntu 22.04 workload vms having duplicate IP addresses #443
While following the instructions on this page to create workload images, I observe that, after I create cb_nullworkload image, if I run vmattach tinyvm twice, the two vms created have the same IP addresses from DHCP server, because:
Ubuntu 22.04 system uses systemd-networkd service to get IP address from DHCP server. It sends machine id (/etc/machine-id) by default.
cb_nullworkload image has /etc/machine-id. Since there isn't a mechanism to remove or recreate the machine id when creating new vms, all vms created from the image have the same machine id and hence the same IP addresses.
I considered a few approaches:
Use cloud-init to recreate machine-id on vm first start-up. Unfortuantely it's impossible. See the discussion here
Use cloud-init to change the default behavior of systemd-networkd. cloud-init (netplan actually) has a dhcp-identifier directive. If its value is 'mac', cloud-init adds "ClientIdentifier=mac" line to systemd-networkd config file and changes its defualt behavior. So I used this approach to create initial image and thought systemd-networkd config should persist. Unfortunately that's not the case. As cbtool also uses cloud-init when creating vm and doesn't provide network-config file, it looks like that's considered a config change by cloud-init and new systemd-networkd config file is generated which doesn't include the "ClientIdentifier=mac" line.
So I ended up removing machine-id manually after running vmcapture:
It turns out that install script has this support already. See its --cleanupimageid option. Below is the code in lib/auxiliary/dependencies.py which implements the option:
I'm reopening the issue to request a small change. When user runs "vmattach check:<base_image>::" command, CBTOOL should add "--cleanupimageid" option to the generated command. Example:
Activity
rayx commentedon Jul 3, 2024
It turns out that
installscript has this support already. See its--cleanupimageidoption. Below is the code inlib/auxiliary/dependencies.pywhich implements the option:rayx commentedon Jul 4, 2024
I'm reopening the issue to request a small change. When user runs "vmattach check:<base_image>::" command, CBTOOL should add "--cleanupimageid" option to the generated command. Example:
I believe this can be implemented by modifying
initialize_objectfunction inlib/operations/base_operations.py.