-
-
Save jimrollenhagen/b6b45aa43878cdc89d89 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@hooks.add_hook('build_instance') | |
@wrap_exception() | |
@reverts_task_state | |
@wrap_instance_event | |
@wrap_instance_fault | |
def _do_build_and_run_instance(self, context, instance, image, | |
request_spec, filter_properties, admin_password, injected_files, | |
requested_networks, security_groups, block_device_mapping, | |
node=None, limits=None): | |
# [...] | |
except exception.RescheduledException as e: | |
# [...] | |
# NOTE(comstud): Deallocate networks if the driver wants | |
# us to do so. | |
LOG.debug('rm12321 pre deallocated network_allocated: {}'.format(instance.system_metadata.get('network_allocated')), instance=instance) | |
if self.driver.deallocate_networks_on_reschedule(instance): | |
self._cleanup_allocated_networks(context, instance, | |
requested_networks) | |
else: | |
# NOTE(alex_xu): Network already allocated and we don't | |
# want to deallocate them before rescheduling. But we need | |
# cleanup those network resource setup on this host before | |
# rescheduling. | |
self.network_api.cleanup_instance_network_on_host( | |
context, instance, self.host) | |
instance.task_state = task_states.SCHEDULING | |
LOG.debug('rm12321 post deallocated network_allocated: {}'.format(instance.system_metadata.get('network_allocated')), instance=instance) | |
LOG.debug('rm12321 post deallocated what changed: {}'.format(instance.obj_what_changed()), instance=instance) | |
instance.save() | |
LOG.debug('rm12321 post save deallocated network_allocated: {}'.format(instance.system_metadata.get('network_allocated')), instance=instance) | |
[...] | |
############################################################# | |
def _cleanup_allocated_networks(self, context, instance, | |
requested_networks): | |
try: | |
self._deallocate_network(context, instance, requested_networks) | |
except Exception: | |
msg = _LE('Failed to deallocate networks') | |
LOG.exception(msg, instance=instance) | |
return | |
LOG.debug('rm12321 _cleanup_allocated_networks pre-set network_allocated: {}'.format(instance.system_metadata.get('network_allocated')), instance=instance) | |
instance.system_metadata['network_allocated'] = 'False' | |
LOG.debug('rm12321 _cleanup_allocated_networks what changed: {}'.format(instance.obj_what_changed()), instance=instance) | |
LOG.debug('rm12321 _cleanup_allocated_networks sysmeta: {}; old_sysmeta: {}'.format(instance.system_metadata, instance._orig_system_metadata), instance=instance) | |
try: | |
instance.save() | |
except exception.InstanceNotFound: | |
# NOTE(alaski): It's possible that we're cleaning up the networks | |
# because the instance was deleted. If that's the case then this | |
# exception will be raised by instance.save() | |
pass | |
########################################################### | |
def _allocate_network_async(self, context, instance, requested_networks, | |
macs, security_groups, is_vpn, dhcp_options): | |
# [...] | |
for attempt in range(1, attempts + 1): | |
try: | |
nwinfo = self.network_api.allocate_for_instance( | |
context, instance, vpn=is_vpn, | |
requested_networks=requested_networks, | |
macs=macs, | |
security_groups=security_groups, | |
dhcp_options=dhcp_options) | |
LOG.debug('Instance network_info: |%s|', nwinfo, | |
instance=instance) | |
sys_meta = instance.system_metadata | |
LOG.debug('rm12321 _async_allocate_network, meta: {}'.format(sys_meta.get('network_allocated')), instance=instance) | |
sys_meta['network_allocated'] = 'True' | |
LOG.debug('rm12321 _async_allocate_networks sysmeta: {}; old_sysmeta: {}'.format(instance.system_metadata, instance._orig_system_metadata), instance=instance) | |
LOG.debug('rm12321 _async_allocate_networks what changed: {}'.format(instance.obj_what_changed()), instance=instance) | |
self._instance_update(context, instance.uuid, | |
system_metadata=sys_meta) | |
LOG.debug('rm12321 _async_allocate_network saved, meta: {}'.format(sys_meta.get('network_allocated')), instance=instance) | |
return nwinfo | |
except Exception: | |
# [...] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Apr 24 16:34:28 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.744 28248 DEBUG nova.compute.manager [-] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _async_allocate_network, meta: False _allocate_network_async /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:1781 | |
Apr 24 16:34:28 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.744 28248 DEBUG nova.compute.manager [-] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _async_allocate_networks sysmeta: {u'image_com.rackspace__1__build_managed': u'1', u'image_com.rackspace__1__visible_rackconnect': u'0', u'image_cache_in_nova': u'True', u'image_com.rackspace__1__source': u'kickstart', u'image_com.rackspace__1__visible_core': u'0', u'image_min_ram': u'512', u'image_os_distro': u'debian', u'image_com.rackspace__1__options': u'0', u'network_allocated': 'True', u'image_org.openstack__1__os_version': u'unstable', u'image_org.openstack__1__os_distro': u'org.debian', u'image_org.openstack__1__architecture': u'x64', u'image_base_image_ref': u'dcd093e2-12ce-445a-9a39-3945f2959ac2', u'image_os_type': u'linux', u'image_com.rackspace__1__release_version': u'10', u'image_com.rackspace__1__build_core': u'1', u'image_image_type': u'base', u'image_com.rackspace__1__build_rackconnect': u'1', u'image_auto_disk_config': u'disabled', u'image_disk_format': u'qcow2', u'image_com.rackspace__1__platform_target': u'PublicCloud', u'image_vm_mode': u'metal', u'image_com.rackspace__1__visible_managed': u'0', u'image_com.rackspace__1__release_build_date': u'2015-03-20_19-37-14', u'image_flavor_classes': u'onmetal', u'image_com.rackspace__1__release_id': u'303', u'image_container_format': u'bare', u'image_min_disk': u'32'}; old_sysmeta: {u'image_os_type': u'linux', u'image_com.rackspace__1__release_version': u'10', u'image_com.rackspace__1__build_managed': u'1', u'image_com.rackspace__1__build_core': u'1', u'image_com.rackspace__1__visible_rackconnect': u'0', u'image_com.rackspace__1__options': u'0', u'image_com.rackspace__1__source': u'kickstart', u'image_image_type': u'base', u'image_com.rackspace__1__release_id': u'303', u'image_auto_disk_config': u'disabled', u'image_com.rackspace__1__visible_core': u'0', u'image_min_ram': u'512', u'image_disk_format': u'qcow2', u'image_com.rackspace__1__platform_target': u'PublicCloud', u'image_com.rackspace__1__build_rackconnect': u'1', u'image_os_distro': u'debian', u'image_vm_mode': u'metal', u'image_com.rackspace__1__visible_managed': u'0', u'image_min_disk': u'32', u'image_flavor_classes': u'onmetal', u'image_cache_in_nova': u'True', u'network_allocated': u'False', u'image_org.openstack__1__os_version': u'unstable', u'image_org.openstack__1__os_distro': u'org.debian', u'image_container_format': u'bare', u'image_org.openstack__1__architecture': u'x64', u'image_com.rackspace__1__release_build_date': u'2015-03-20_19-37-14', u'image_base_image_ref': u'dcd093e2-12ce-445a-9a39-3945f2959ac2'} _allocate_network_async /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:1783 | |
Apr 24 16:34:28 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.745 28248 DEBUG nova.compute.manager [-] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _async_allocate_networks what changed: set(['flavor', 'system_metadata']) _allocate_network_async /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:1784 | |
Apr 24 16:34:28 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.812 28248 DEBUG nova.objects.instance [-] Lazy-loading `flavor' on Instance uuid 18f8b5ba-392b-4446-bb0e-61cd9697a0be obj_load_attr /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/objects/instance.py:994 | |
Apr 24 16:34:28 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.861 28248 DEBUG nova.objects.instance [-] Lazy-loading `metadata' on Instance uuid 18f8b5ba-392b-4446-bb0e-61cd9697a0be obj_load_attr /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/objects/instance.py:994 | |
Apr 24 16:34:28 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.899 28248 DEBUG nova.objects.instance [req-83ac8858-02c3-47f9-a155-74f303716752 - - - - -] Lazy-loading `info_cache' on Instance uuid 18f8b5ba-392b-4446-bb0e-61cd9697a0be obj_load_attr /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/objects/instance.py:994 | |
Apr 24 16:34:29 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:34:28.985 28248 DEBUG nova.compute.manager [req-83ac8858-02c3-47f9-a155-74f303716752 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _async_allocate_network saved, meta: True _allocate_network_async /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:1787 | |
[...] | |
Apr 24 16:42:42 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:42.458 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 pre deallocated network_allocated: True _do_build_and_run_instance /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2194 | |
Apr 24 16:42:44 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:44.041 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _cleanup_allocated_networks pre-set network_allocated: True _cleanup_allocated_networks /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2460 | |
Apr 24 16:42:44 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:44.042 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _cleanup_allocated_networks what changed: set(['flavor']) _cleanup_allocated_networks /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2463 | |
Apr 24 16:42:44 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:44.043 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 _cleanup_allocated_networks sysmeta: {u'image_com.rackspace__1__build_managed': u'1', u'image_com.rackspace__1__visible_rackconnect': u'0', u'image_cache_in_nova': u'True', u'image_com.rackspace__1__source': u'kickstart', u'image_com.rackspace__1__visible_core': u'0', u'image_min_ram': u'512', u'image_os_distro': u'debian', u'image_com.rackspace__1__options': u'0', u'network_allocated': 'False', u'image_org.openstack__1__os_version': u'unstable', u'image_org.openstack__1__os_distro': u'org.debian', u'image_org.openstack__1__architecture': u'x64', u'image_base_image_ref': u'dcd093e2-12ce-445a-9a39-3945f2959ac2', u'image_os_type': u'linux', u'image_com.rackspace__1__release_version': u'10', u'image_com.rackspace__1__build_core': u'1', u'image_image_type': u'base', u'image_com.rackspace__1__build_rackconnect': u'1', u'image_auto_disk_config': u'disabled', u'image_disk_format': u'qcow2', u'image_com.rackspace__1__platform_target': u'PublicCloud', u'image_vm_mode': u'metal', u'image_com.rackspace__1__visible_managed': u'0', u'image_com.rackspace__1__release_build_date': u'2015-03-20_19-37-14', u'image_flavor_classes': u'onmetal', u'image_com.rackspace__1__release_id': u'303', u'image_container_format': u'bare', u'image_min_disk': u'32'}; old_sysmeta: {u'image_os_type': u'linux', u'image_com.rackspace__1__release_version': u'10', u'image_com.rackspace__1__build_managed': u'1', u'image_com.rackspace__1__build_core': u'1', u'image_com.rackspace__1__visible_rackconnect': u'0', u'image_com.rackspace__1__options': u'0', u'image_com.rackspace__1__source': u'kickstart', u'image_image_type': u'base', u'image_com.rackspace__1__release_id': u'303', u'image_auto_disk_config': u'disabled', u'image_com.rackspace__1__visible_core': u'0', u'image_min_ram': u'512', u'image_disk_format': u'qcow2', u'image_com.rackspace__1__platform_target': u'PublicCloud', u'image_com.rackspace__1__build_rackconnect': u'1', u'image_os_distro': u'debian', u'image_vm_mode': u'metal', u'image_com.rackspace__1__visible_managed': u'0', u'image_min_disk': u'32', u'image_flavor_classes': u'onmetal', u'image_cache_in_nova': u'True', u'network_allocated': u'False', u'image_org.openstack__1__os_version': u'unstable', u'image_org.openstack__1__os_distro': u'org.debian', u'image_container_format': u'bare', u'image_org.openstack__1__architecture': u'x64', u'image_com.rackspace__1__release_build_date': u'2015-03-20_19-37-14', u'image_base_image_ref': u'dcd093e2-12ce-445a-9a39-3945f2959ac2'} _cleanup_allocated_networks /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2464 | |
Apr 24 16:42:44 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:44.082 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 post deallocated network_allocated: False _do_build_and_run_instance /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2206 | |
Apr 24 16:42:44 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:44.083 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 post deallocated what changed: set(['flavor', 'task_state']) _do_build_and_run_instance /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2207 | |
Apr 24 16:42:44 ironic-compute01.m0002.preprod-ord.ohthree.com 2015-04-24 16:42:44.233 28248 DEBUG nova.compute.manager [req-d61d165c-3fb7-4513-b894-7459caae4b89 - - - - -] [instance: 18f8b5ba-392b-4446-bb0e-61cd9697a0be] rm12321 post save deallocated network_allocated: True _do_build_and_run_instance /opt/rackstack/rackstack.228.26/nova/lib/python2.7/site-packages/nova/compute/manager.py:2209 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The only code that touches system_metadata['network_allocated'] is here.
Note line 9 in the log sees network_allocated as True, then after it is set to False, line 11 shows that _orig_system_metadata shows it as False as well (before saving). Maybe instance needs a refresh() before setting that attribute?