Allows to configure a dedicated migration network.

This commits adds a new extra binding (migration) and
its corresponding fallback configuration flag (libvirt-
migration-network) that allows to specify a space or an
existing CIDR formatted network (if the config flag is pre-
ferred) that will be seleced as the inbound address to be used
as a the live migration target.

For the case of any openstack release >= ocata,
the live_migration_inbound_addr variable will be set
as well as the libvirt_migration_scheme (set to SSH
by default).

For older releases, the behavior remains as before,
as the only remaining option is to setup libvirt
to bind in a insecure tcp connection, so we keep it
as the current live_migration_uri.

The reason of not using an extra-binding exclusively relies
on the back-compability of the change, this needs
to be applied on existing clouds where updating
the bindings on deployed application
isn't possible due to LP: #1796653.

For fresh/new deployments, the migration extra-binding
has been defined and used with precedence over the
libvirt-migration-network variable.

Change-Id: I2f8c0a1e822ad6a90e23cd8009e181b8f86d765a
Closes-Bug: #1680531
Signed-off-by: Jorge Niedbalski <jnr@metaklass.org>
This commit is contained in:
Jorge Niedbalski 2019-08-08 15:04:28 -04:00 committed by Jorge Niedbalski
parent 4a4908160d
commit 0905a447ad
8 changed files with 87 additions and 3 deletions

View File

@ -534,3 +534,18 @@ options:
description: | description: |
Ensure notifications are included in the log files. It will set an additional Ensure notifications are included in the log files. It will set an additional
log driver for oslo messaging notifications. log driver for oslo messaging notifications.
libvirt-migration-network:
type: string
default:
description: |
Specify a network in cidr notation (192.168.0.0/24),
which directs libvirt to use a specific network
address as the live_migration_inbound_addr to make
use of a dedicated migration network if possible.
.
Please note that if the migration binding has been
declared and set, the primary address for that space has precedence
over this configuration option.
.
This option doesn't have any effect on clouds running
a release < Ocata.

View File

@ -21,6 +21,7 @@ import uuid
from charmhelpers.core.unitdata import kv from charmhelpers.core.unitdata import kv
from charmhelpers.contrib.openstack import context from charmhelpers.contrib.openstack import context
from charmhelpers.core.host import ( from charmhelpers.core.host import (
lsb_release, lsb_release,
CompareHostReleases, CompareHostReleases,
@ -53,7 +54,6 @@ from charmhelpers.contrib.network.ip import (
get_relation_ip, get_relation_ip,
) )
# This is just a label and it must be consistent across # This is just a label and it must be consistent across
# nova-compute nodes to support live migration. # nova-compute nodes to support live migration.
CEPH_SECRET_UUID = '514c9fca-8cbe-11e2-9c52-3bc8c7819472' CEPH_SECRET_UUID = '514c9fca-8cbe-11e2-9c52-3bc8c7819472'
@ -199,8 +199,14 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
if config('enable-live-migration') and \ if config('enable-live-migration') and \
config('migration-auth-type') == 'ssh': config('migration-auth-type') == 'ssh':
# nova.conf migration_address = get_relation_ip(
ctxt['live_migration_uri'] = 'qemu+ssh://%s/system' 'migration', cidr_network=config('libvirt-migration-network'))
if cmp_os_release >= 'ocata':
ctxt['live_migration_scheme'] = config('migration-auth-type')
ctxt['live_migration_inbound_addr'] = migration_address
else:
ctxt['live_migration_uri'] = 'qemu+ssh://%s/system'
if config('enable-live-migration'): if config('enable-live-migration'):
ctxt['live_migration_permit_post_copy'] = \ ctxt['live_migration_permit_post_copy'] = \

View File

@ -24,6 +24,7 @@ provides:
scope: container scope: container
extra-bindings: extra-bindings:
internal: internal:
migration:
requires: requires:
amqp: amqp:
interface: rabbitmq interface: rabbitmq

View File

@ -215,6 +215,12 @@ rbd_secret_uuid = {{ rbd_secret_uuid }}
{% if live_migration_uri -%} {% if live_migration_uri -%}
live_migration_uri = {{ live_migration_uri }} live_migration_uri = {{ live_migration_uri }}
{% endif -%} {% endif -%}
{% if live_migration_scheme -%}
live_migration_scheme = {{ live_migration_scheme }}
{% endif -%}
{% if live_migration_inbound_addr -%}
live_migration_inbound_addr = {{ live_migration_inbound_addr }}
{% endif -%}
{% if live_migration_permit_post_copy -%} {% if live_migration_permit_post_copy -%}
live_migration_permit_post_copy = {{ live_migration_permit_post_copy }} live_migration_permit_post_copy = {{ live_migration_permit_post_copy }}
{% endif -%} {% endif -%}

View File

@ -223,6 +223,12 @@ rbd_secret_uuid = {{ rbd_secret_uuid }}
{% if live_migration_uri -%} {% if live_migration_uri -%}
live_migration_uri = {{ live_migration_uri }} live_migration_uri = {{ live_migration_uri }}
{% endif -%} {% endif -%}
{% if live_migration_scheme -%}
live_migration_scheme = {{ live_migration_scheme }}
{% endif -%}
{% if live_migration_inbound_addr -%}
live_migration_inbound_addr = {{ live_migration_inbound_addr }}
{% endif -%}
{% if live_migration_permit_post_copy -%} {% if live_migration_permit_post_copy -%}
live_migration_permit_post_copy = {{ live_migration_permit_post_copy }} live_migration_permit_post_copy = {{ live_migration_permit_post_copy }}
{% endif -%} {% endif -%}

View File

@ -235,6 +235,12 @@ rbd_secret_uuid = {{ rbd_secret_uuid }}
{% if live_migration_uri -%} {% if live_migration_uri -%}
live_migration_uri = {{ live_migration_uri }} live_migration_uri = {{ live_migration_uri }}
{% endif -%} {% endif -%}
{% if live_migration_scheme -%}
live_migration_scheme = {{ live_migration_scheme }}
{% endif -%}
{% if live_migration_inbound_addr -%}
live_migration_inbound_addr = {{ live_migration_inbound_addr }}
{% endif -%}
{% if live_migration_permit_post_copy -%} {% if live_migration_permit_post_copy -%}
live_migration_permit_post_copy = {{ live_migration_permit_post_copy }} live_migration_permit_post_copy = {{ live_migration_permit_post_copy }}
{% endif -%} {% endif -%}

View File

@ -235,6 +235,12 @@ rbd_secret_uuid = {{ rbd_secret_uuid }}
{% if live_migration_uri -%} {% if live_migration_uri -%}
live_migration_uri = {{ live_migration_uri }} live_migration_uri = {{ live_migration_uri }}
{% endif -%} {% endif -%}
{% if live_migration_scheme -%}
live_migration_scheme = {{ live_migration_scheme }}
{% endif -%}
{% if live_migration_inbound_addr -%}
live_migration_inbound_addr = {{ live_migration_inbound_addr }}
{% endif -%}
{% if live_migration_permit_post_copy -%} {% if live_migration_permit_post_copy -%}
live_migration_permit_post_copy = {{ live_migration_permit_post_copy }} live_migration_permit_post_copy = {{ live_migration_permit_post_copy }}
{% endif -%} {% endif -%}

View File

@ -56,6 +56,10 @@ def fake_log(msg, level=None):
print('[juju test log ({})] {}'.format(level, msg)) print('[juju test log ({})] {}'.format(level, msg))
def raise_no_space(self):
raise context.NoNetworkBinding
class FakeUnitdata(object): class FakeUnitdata(object):
def __init__(self, **kwargs): def __init__(self, **kwargs):
@ -344,6 +348,40 @@ class NovaComputeContextTests(CharmTestCase):
'force_raw_images': True, 'force_raw_images': True,
'reserved_host_memory': 512}, libvirt()) 'reserved_host_memory': 512}, libvirt())
def test_libvirt_context_without_migration_network(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
self.test_config.set('enable-live-migration', True)
self.test_config.set('migration-auth-type', 'ssh')
self.os_release.return_value = 'kilo'
self.assertEquals(context.NovaComputeLibvirtContext()()[
'live_migration_uri'], 'qemu+ssh://%s/system')
def test_libvirt_context_with_migration_network(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
self.test_config.set('enable-live-migration', True)
self.test_config.set('migration-auth-type', 'ssh')
self.test_config.set('libvirt-migration-network', '10.5.0.0/16')
self.os_release.return_value = 'rocky'
context.NovaComputeLibvirtContext()()
self.get_relation_ip.assert_called_with('migration',
cidr_network="10.5.0.0/16")
def test_libvirt_context_with_migration_space(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'xenial'}
self.test_config.set('enable-live-migration', True)
self.os_release.return_value = 'ocata'
self.get_relation_ip.return_value = "10.5.0.5"
libvirt_context = context.NovaComputeLibvirtContext()()
self.get_relation_ip.assert_called_with('migration',
cidr_network=None)
self.assertTrue('live_migration_uri' not in libvirt_context.keys())
self.assertEquals(libvirt_context['live_migration_scheme'], 'ssh')
self.assertEquals(libvirt_context['live_migration_inbound_addr'],
'10.5.0.5')
def test_libvirt_bin_context_migration_tcp_listen_with_auto_converge(self): def test_libvirt_bin_context_migration_tcp_listen_with_auto_converge(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid}) self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'} self.lsb_release.return_value = {'DISTRIB_CODENAME': 'lucid'}