diff options
author | Artom Lifshitz <alifshit@redhat.com> | 2019-07-19 11:35:24 -0400 |
---|---|---|
committer | Artom Lifshitz <alifshit@redhat.com> | 2019-07-22 16:30:12 -0400 |
commit | 028a8e949e9b9b5731e7f5f283375533ab6f85fa (patch) | |
tree | bcf6fbe976a0df2dfa711243f562757c0119e30f /nova/virt | |
parent | 95a35cbee44f8e97aa6d3a04820175c052f03cb3 (diff) | |
download | nova-028a8e949e9b9b5731e7f5f283375533ab6f85fa.tar.gz |
libvirt: move checking CONF.my_ip to init_host()
Migrations use the libvirt driver's get_host_ip_addr() method to
determine the dest_host field of the migration object.
get_host_ip_addr() checks whether CONF.my_ip is actually assigned to
one of the host's interfaces. It does so by calling
get_machine_ips(), which iterates over all of the host's interfaces.
If the host has many interfaces, this can take a long time, and
introduces needless delays in processing the migration.
get_machine_ips() is only used to print a warning, so this patch moves
the get_machine_ips() call to a single method in init_host(). This
way, a warning is still emitted at compute service startup, and
migration progress is not needlessly slowed down.
NOTE(artom) While the following paragraph still applies, the poison
patch will not be backported. Stubbing out use of
netifaces.interfaces() is still a good thing to do, however.
This patch also has a chicken and egg problem with the patch on top of
it, which poisons use of netifaces.interfaces() in tests. While this
patch fixes all the tests that break with that poison, it starts
breaking different tests because of the move of get_machine_ips() into
init_host(). Therefore, while not directly related to the bug, this
patch also preventatively mocks or stubs out any use of
get_machine_ips() that will get poisoned with the subsequent patch.
(cherry picked from commit 30d8159d4ee51a26a03de1cb134ea64c6c07ffb2)
(cherry picked from commit 560317c766afc4a4c4c5017ecfc9ce432fe63ea7)
(cherry picked from commit 65d2e455e323a627ef228ed57a1f0c86d8252665)
Conflicts:
nova/tests/unit/virt/libvirt/fakelibvirt.py
Due to 23fd6c2287f1e68336e7752246999de739b9f7c0 which mocked out
get_fs_info() at the same place as this patch mocks out
get_machine_ips().
nova/virt/libvirt/driver.py
Due to cbc28f0d15287dcf24a07f835210affa41c38993 which added
_check_file_backed_memory_support() to init_host() at the same
place this patch added _check_my_ip().
Closes-bug: 1837075
Change-Id: I58a4038b04d5a9c28927d914e71609e4deea3d9f
Diffstat (limited to 'nova/virt')
-rw-r--r-- | nova/virt/libvirt/driver.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 321af13dd9..16843b3707 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -500,6 +500,8 @@ class LibvirtDriver(driver.ComputeDriver): self._set_multiattach_support() + self._check_my_ip() + if (CONF.libvirt.virt_type == 'lxc' and not (CONF.libvirt.uid_maps and CONF.libvirt.gid_maps)): LOG.warning("Running libvirt-lxc without user namespaces is " @@ -621,6 +623,13 @@ class LibvirtDriver(driver.ComputeDriver): 'versions of QEMU and libvirt. QEMU must be less than ' '2.10 or libvirt must be greater than or equal to 3.10.') + def _check_my_ip(self): + ips = compute_utils.get_machine_ips() + if CONF.my_ip not in ips: + LOG.warning('my_ip address (%(my_ip)s) was not found on ' + 'any of the interfaces: %(ifaces)s', + {'my_ip': CONF.my_ip, 'ifaces': ", ".join(ips)}) + def _prepare_migration_flags(self): migration_flags = 0 @@ -3226,11 +3235,6 @@ class LibvirtDriver(driver.ComputeDriver): return self._get_console_output_file(instance, console_log) def get_host_ip_addr(self): - ips = compute_utils.get_machine_ips() - if CONF.my_ip not in ips: - LOG.warning('my_ip address (%(my_ip)s) was not found on ' - 'any of the interfaces: %(ifaces)s', - {'my_ip': CONF.my_ip, 'ifaces': ", ".join(ips)}) return CONF.my_ip def get_vnc_console(self, context, instance): |