Rackspace-DOT / nova-agent

Other
4 stars 18 forks source link

nova-agent incorrectly preserving old MAC addresses #60

Closed chder closed 5 years ago

chder commented 6 years ago

https://github.com/Rackspace-DOT/nova-agent/blob/master/novaagent/libs/centos.py#L109-L113

Over in this block from https://github.com/Rackspace-DOT/nova-agent/pull/51 nova-agent is saving old settings that don't match a blacklist.

HWADDR is not blacklisted and is not otherwise set by nova-agent so this is preserving leading to networking breaking when building from an image where the source server had that set.

This is easy enough to reproduce on the Rackspace Cloud. On a test server (and rather going through the whole process of taking an image and building a new server):

# echo 'HWADDR=90:10:00:11:22:33' >> /etc/sysconfig/network-scripts/ifcfg-eth1
# xenstore-write data/host/123 '{"name":"resetnetwork","value":""}'

wait a few moments and eth1 is now broken and nova-agent reported an error

# xenstore-read data/guest/123
{"message": "Error restarting network", "returncode": "1"}

Fix it:

# sed -i 's/HWADDR/#HWADDR/' /etc/sysconfig/network-scripts/ifcfg-eth1
# xenstore-write data/host/456 '{"name":"resetnetwork","value":""}'

wait a few moments

# xenstore-read data/guest/456
{"message": "", "returncode": "0"}

And it's happy again.

This edit to centos.py lets it survive that initial scenario.

# grep -n HWADDR /usr/lib/python2.7/site-packages/novaagent/libs/centos.py
112:            '^IPADDR\d?', '^NETMASK\d?', '^HWADDR=', '^#', '^\s+'
ghost commented 5 years ago

Released with https://github.com/Rackspace-DOT/nova-agent/releases/tag/2.1.19