Fix problem with 'storage.zfs_pool_name' being removed from lxd 3
LXD 3.x onwards removes the key 'storage.zfs_pool_name' from the config. This means the storage_pool API needs to be used to get the name of the pool that juju is using for ZFS. This is a temporary fix until storage pools can be threaded into nova-lxd properly. This occurs on bionic due to LXD 3 being shipped as standard. Change-Id: I6527640438331b86f2140cf0a772f7d207a6fd40 Closes-Bug: #1782329
This commit is contained in:
parent
a02fce0d31
commit
f1bbc03b65
@ -79,6 +79,11 @@ r="$r|(?:tempest\.api\.compute\.volumes\.test_attach_volume\.AttachVolumeShelveT
|
|||||||
r="$r|(?:.*test_get_server_diagnostics.*)"
|
r="$r|(?:.*test_get_server_diagnostics.*)"
|
||||||
#test_get_server_diagnostics
|
#test_get_server_diagnostics
|
||||||
|
|
||||||
|
# XXX: ajkavanagh (2018-07-23): disable test_show_update_rebuild_list_server as nova-lxd doesn't have the
|
||||||
|
# 'supports_trusted_certs' capability, and the test uses it.
|
||||||
|
# BUG: https://bugs.launchpad.net/nova-lxd/+bug/1783080
|
||||||
|
r="$r|(?:.*ServerShowV263Test.test_show_update_rebuild_list_server.*)"
|
||||||
|
|
||||||
r="$r).*$"
|
r="$r).*$"
|
||||||
|
|
||||||
export DEVSTACK_GATE_TEMPEST_REGEX="$r"
|
export DEVSTACK_GATE_TEMPEST_REGEX="$r"
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
import mock
|
import mock
|
||||||
|
import uuid
|
||||||
|
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova.tests.unit import fake_instance
|
from nova.tests.unit import fake_instance
|
||||||
@ -101,7 +102,7 @@ def _fake_instance():
|
|||||||
_instance_values = {
|
_instance_values = {
|
||||||
'display_name': 'fake_display_name',
|
'display_name': 'fake_display_name',
|
||||||
'name': 'fake_name',
|
'name': 'fake_name',
|
||||||
'uuid': 'fake_uuid',
|
'uuid': uuid.uuid1(),
|
||||||
'image_ref': 'fake_image',
|
'image_ref': 'fake_image',
|
||||||
'vcpus': 1,
|
'vcpus': 1,
|
||||||
'memory_mb': 512,
|
'memory_mb': 512,
|
||||||
|
@ -213,7 +213,9 @@ class TestDetachEphemeral(test.NoDBTestCase):
|
|||||||
lxd_config = {'environment': {'storage': 'zfs'},
|
lxd_config = {'environment': {'storage': 'zfs'},
|
||||||
'config': {'storage.zfs_pool_name': 'zfs'}}
|
'config': {'storage.zfs_pool_name': 'zfs'}}
|
||||||
|
|
||||||
storage.detach_ephemeral(block_device_info, lxd_config, instance)
|
client = mock.Mock()
|
||||||
|
storage.detach_ephemeral(
|
||||||
|
client, block_device_info, lxd_config, instance)
|
||||||
|
|
||||||
block_device_info_get_ephemerals.assert_called_once_with(
|
block_device_info_get_ephemerals.assert_called_once_with(
|
||||||
block_device_info)
|
block_device_info)
|
||||||
@ -239,7 +241,9 @@ class TestDetachEphemeral(test.NoDBTestCase):
|
|||||||
lxd_config = {'environment': {'storage': 'lvm'},
|
lxd_config = {'environment': {'storage': 'lvm'},
|
||||||
'config': {'storage.lvm_vg_name': 'lxd'}}
|
'config': {'storage.lvm_vg_name': 'lxd'}}
|
||||||
|
|
||||||
storage.detach_ephemeral(block_device_info, lxd_config, instance)
|
client = mock.Mock()
|
||||||
|
storage.detach_ephemeral(
|
||||||
|
client, block_device_info, lxd_config, instance)
|
||||||
|
|
||||||
block_device_info_get_ephemerals.assert_called_once_with(
|
block_device_info_get_ephemerals.assert_called_once_with(
|
||||||
block_device_info)
|
block_device_info)
|
||||||
|
@ -661,7 +661,10 @@ class LXDDriver(driver.ComputeDriver):
|
|||||||
self.firewall_driver.unfilter_instance(instance, network_info)
|
self.firewall_driver.unfilter_instance(instance, network_info)
|
||||||
|
|
||||||
lxd_config = self.client.host_info
|
lxd_config = self.client.host_info
|
||||||
storage.detach_ephemeral(block_device_info, lxd_config, instance)
|
storage.detach_ephemeral(self.client,
|
||||||
|
block_device_info,
|
||||||
|
lxd_config,
|
||||||
|
instance)
|
||||||
|
|
||||||
name = pwd.getpwuid(os.getuid()).pw_name
|
name = pwd.getpwuid(os.getuid()).pw_name
|
||||||
|
|
||||||
@ -1039,9 +1042,15 @@ class LXDDriver(driver.ComputeDriver):
|
|||||||
# to support LXD storage pools
|
# to support LXD storage pools
|
||||||
storage_driver = lxd_config['environment']['storage']
|
storage_driver = lxd_config['environment']['storage']
|
||||||
if storage_driver == 'zfs':
|
if storage_driver == 'zfs':
|
||||||
local_disk_info = _get_zpool_info(
|
# NOTE(ajkavanagh) - BUG/1782329 - this is temporary until storage
|
||||||
lxd_config['config']['storage.zfs_pool_name']
|
# pools is implemented. LXD 3 removed the storage.zfs_pool_name
|
||||||
)
|
# key from the config. So, if it fails, we need to grab the
|
||||||
|
# configured storage pool and use that as the name instead.
|
||||||
|
try:
|
||||||
|
pool_name = lxd_config['config']['storage.zfs_pool_name']
|
||||||
|
except KeyError:
|
||||||
|
pool_name = CONF.lxd.pool
|
||||||
|
local_disk_info = _get_zpool_info(pool_name)
|
||||||
else:
|
else:
|
||||||
local_disk_info = _get_fs_info(CONF.lxd.root_dir)
|
local_disk_info = _get_fs_info(CONF.lxd.root_dir)
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from oslo_utils import fileutils
|
from oslo_utils import fileutils
|
||||||
from nova import exception
|
from nova import exception
|
||||||
from nova import utils
|
from nova import utils
|
||||||
@ -21,6 +22,8 @@ from nova.virt import driver
|
|||||||
|
|
||||||
from nova.virt.lxd import common
|
from nova.virt.lxd import common
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def attach_ephemeral(client, block_device_info, lxd_config, instance):
|
def attach_ephemeral(client, block_device_info, lxd_config, instance):
|
||||||
"""Attach ephemeral storage to an instance."""
|
"""Attach ephemeral storage to an instance."""
|
||||||
@ -39,7 +42,15 @@ def attach_ephemeral(client, block_device_info, lxd_config, instance):
|
|||||||
storage_dir = os.path.join(
|
storage_dir = os.path.join(
|
||||||
instance_attrs.storage_path, ephemeral['virtual_name'])
|
instance_attrs.storage_path, ephemeral['virtual_name'])
|
||||||
if storage_driver == 'zfs':
|
if storage_driver == 'zfs':
|
||||||
zfs_pool = lxd_config['config']['storage.zfs_pool_name']
|
# NOTE(ajkavanagh) - BUG/1782329 - this is temporary until
|
||||||
|
# storage pools is implemented. LXD 3 removed the
|
||||||
|
# storage.zfs_pool_name key from the config. So, if it fails,
|
||||||
|
# we need to grab the configured storage pool and use that as
|
||||||
|
# the name instead.
|
||||||
|
try:
|
||||||
|
zfs_pool = lxd_config['config']['storage.zfs_pool_name']
|
||||||
|
except KeyError:
|
||||||
|
zfs_pool = CONF.lxd.pool
|
||||||
|
|
||||||
utils.execute(
|
utils.execute(
|
||||||
'zfs', 'create',
|
'zfs', 'create',
|
||||||
@ -92,7 +103,7 @@ def attach_ephemeral(client, block_device_info, lxd_config, instance):
|
|||||||
storage_dir, run_as_root=True)
|
storage_dir, run_as_root=True)
|
||||||
|
|
||||||
|
|
||||||
def detach_ephemeral(block_device_info, lxd_config, instance):
|
def detach_ephemeral(client, block_device_info, lxd_config, instance):
|
||||||
"""Detach ephemeral device from the instance."""
|
"""Detach ephemeral device from the instance."""
|
||||||
ephemeral_storage = driver.block_device_info_get_ephemerals(
|
ephemeral_storage = driver.block_device_info_get_ephemerals(
|
||||||
block_device_info)
|
block_device_info)
|
||||||
@ -101,7 +112,15 @@ def detach_ephemeral(block_device_info, lxd_config, instance):
|
|||||||
|
|
||||||
for ephemeral in ephemeral_storage:
|
for ephemeral in ephemeral_storage:
|
||||||
if storage_driver == 'zfs':
|
if storage_driver == 'zfs':
|
||||||
zfs_pool = lxd_config['config']['storage.zfs_pool_name']
|
# NOTE(ajkavanagh) - BUG/1782329 - this is temporary until
|
||||||
|
# storage pools is implemented. LXD 3 removed the
|
||||||
|
# storage.zfs_pool_name key from the config. So, if it fails,
|
||||||
|
# we need to grab the configured storage pool and use that as
|
||||||
|
# the name instead.
|
||||||
|
try:
|
||||||
|
zfs_pool = lxd_config['config']['storage.zfs_pool_name']
|
||||||
|
except KeyError:
|
||||||
|
zfs_pool = CONF.lxd.pool
|
||||||
|
|
||||||
utils.execute(
|
utils.execute(
|
||||||
'zfs', 'destroy',
|
'zfs', 'destroy',
|
||||||
|
Loading…
Reference in New Issue
Block a user