Filter virbr0 when finding addresses for a machine #6850
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Without filtering virbr0 we run into things where 'bootstrap' tries to use
the virbr0 address which exists both remotely and locally.
We were already filtering lxc and lxdbr0, this just includes virbr0
to be omitted as well.
This also cleans up the logging output by aggregating the addresses for all bridges in the beginning, and then filtering them all at once, instead of doing them one-by-one. Without this, each IP address that we kept would have 3 entries in the log file that we were keeping it.
Should help with bug #1644429.
To test this, you'll want to bootstrap and install libvirt-bin both locally and on the controller machine. At which point, juju should not think one of the remote machine's valid addresses is 192.168.122.1 (the default virbr0 address.) You can test this using lxd using the following cheats:
Something like these steps:
$ sudo apt install libvirt-bin
$ juju bootstrap lxd test-lxd
$ juju switch controller
$ juju ssh 0
$$ sudo apt install libvirt-bin
$$ sudo brctl addbr virbr0
$$ sudo ip addr add 192.168.122.1 dev virbr0
$$ service restart jujud-machine-0
$$ ^D
$ juju show-machine 0
This patch may not be fully sufficient to filter the virbr0 for 'lxd', because lxd itself reports 'virbr0' as one of the valid interfaces to contact the machine, and the above only filters our "machine addresses" not the addresses that the Provider reports. However, MAAS and AWS shouldn't report virbr0 as one of the known-to-the-provider addresses, which is what this patch helps with.
I did dump the database with and without this patch and saw that the new way does suppress virbr0 just like we suppress other bridge ip addresses.
This is a forward port of #6849 to 2.2.