Merge "Ensure instance_info is clean before deploy and after failure" into stable/stein
This commit is contained in:
commit
3f2e391389
|
@ -34,6 +34,7 @@ LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
_CREATED_PORTS = 'metalsmith_created_ports'
|
_CREATED_PORTS = 'metalsmith_created_ports'
|
||||||
_ATTACHED_PORTS = 'metalsmith_attached_ports'
|
_ATTACHED_PORTS = 'metalsmith_attached_ports'
|
||||||
|
_PRESERVE_INSTANCE_INFO_KEYS = {'capabilities', 'traits'}
|
||||||
|
|
||||||
|
|
||||||
class Provisioner(_utils.GetNodeMixin):
|
class Provisioner(_utils.GetNodeMixin):
|
||||||
|
@ -283,7 +284,7 @@ class Provisioner(_utils.GetNodeMixin):
|
||||||
|
|
||||||
capabilities['boot_option'] = 'netboot' if netboot else 'local'
|
capabilities['boot_option'] = 'netboot' if netboot else 'local'
|
||||||
|
|
||||||
instance_info = node.instance_info.copy()
|
instance_info = self._clean_instance_info(node.instance_info)
|
||||||
instance_info['root_gb'] = root_size_gb
|
instance_info['root_gb'] = root_size_gb
|
||||||
instance_info['capabilities'] = capabilities
|
instance_info['capabilities'] = capabilities
|
||||||
instance_info[self.HOSTNAME_FIELD] = hostname
|
instance_info[self.HOSTNAME_FIELD] = hostname
|
||||||
|
@ -364,6 +365,11 @@ class Provisioner(_utils.GetNodeMixin):
|
||||||
nodes, 'active', timeout=timeout)
|
nodes, 'active', timeout=timeout)
|
||||||
return [_instance.Instance(self.connection, node) for node in nodes]
|
return [_instance.Instance(self.connection, node) for node in nodes]
|
||||||
|
|
||||||
|
def _clean_instance_info(self, instance_info):
|
||||||
|
return {key: value
|
||||||
|
for key, value in instance_info.items()
|
||||||
|
if key in _PRESERVE_INSTANCE_INFO_KEYS}
|
||||||
|
|
||||||
def _clean_up(self, node, nics=None):
|
def _clean_up(self, node, nics=None):
|
||||||
if nics is None:
|
if nics is None:
|
||||||
created_ports = node.extra.get(_CREATED_PORTS, [])
|
created_ports = node.extra.get(_CREATED_PORTS, [])
|
||||||
|
@ -376,17 +382,14 @@ class Provisioner(_utils.GetNodeMixin):
|
||||||
extra = node.extra.copy()
|
extra = node.extra.copy()
|
||||||
for item in (_CREATED_PORTS, _ATTACHED_PORTS):
|
for item in (_CREATED_PORTS, _ATTACHED_PORTS):
|
||||||
extra.pop(item, None)
|
extra.pop(item, None)
|
||||||
instance_info = node.instance_info.copy()
|
LOG.debug('Updating node %(node)s with empty instance info (was '
|
||||||
instance_info.pop(self.HOSTNAME_FIELD, None)
|
'%(iinfo)s) and extras %(extra)s and releasing the lock',
|
||||||
LOG.debug('Updating node %(node)s with instance info %(iinfo)s '
|
|
||||||
'and extras %(extra)s and releasing the lock',
|
|
||||||
{'node': _utils.log_res(node),
|
{'node': _utils.log_res(node),
|
||||||
'iinfo': instance_info,
|
'iinfo': node.instance_info,
|
||||||
'extra': extra})
|
'extra': extra})
|
||||||
try:
|
try:
|
||||||
self.connection.baremetal.update_node(
|
self.connection.baremetal.update_node(
|
||||||
node, instance_info=instance_info, extra=extra,
|
node, instance_info={}, extra=extra, instance_id=None)
|
||||||
instance_id=None)
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
LOG.debug('Failed to clear node %(node)s extra: %(exc)s',
|
LOG.debug('Failed to clear node %(node)s extra: %(exc)s',
|
||||||
{'node': _utils.log_res(node), 'exc': exc})
|
{'node': _utils.log_res(node), 'exc': exc})
|
||||||
|
|
|
@ -510,6 +510,9 @@ class TestProvisionNode(Base):
|
||||||
self.image.ramdisk_id = None
|
self.image.ramdisk_id = None
|
||||||
del self.instance_info['kernel']
|
del self.instance_info['kernel']
|
||||||
del self.instance_info['ramdisk']
|
del self.instance_info['ramdisk']
|
||||||
|
# Ensure stale values clean up
|
||||||
|
self.node.instance_info['kernel'] = 'bad value'
|
||||||
|
self.node.instance_info['ramdisk'] = 'bad value'
|
||||||
|
|
||||||
self.pr.provision_node(self.node, 'image', [{'network': 'network'}])
|
self.pr.provision_node(self.node, 'image', [{'network': 'network'}])
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes stale ``instance_info`` remaining after deploy failures.
|
||||||
|
- |
|
||||||
|
Cleans up ``instance_info`` before updating it before deployment to make
|
||||||
|
sure not stale information is left there.
|
Loading…
Reference in New Issue