From 8db54f3bd590e71c6c6e383c928aa82fc28b3379 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 29 May 2012 16:04:16 -0400 Subject: Don't query nova-network on startup. Fix bug 999698. nova-compute requested network info for each instance on startup via rpc. If all services get (re)started at the same time, nova-network may not be available to take this request, resulting in a lost request. To combat this issue, get the network info from the cache in the database on startup. If by some chance this information is not correct, it will get fixed up by a periodic task. Change-Id: I0bbd475e078ac2a67c99c2be4711e86d617c609a --- nova/compute/manager.py | 2 +- nova/compute/utils.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 2776ee230..a14a38e88 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -287,7 +287,7 @@ class ComputeManager(manager.SchedulerDependentManager): LOG.debug(_('Current state is %(drv_state)s, state in DB is ' '%(db_state)s.'), locals(), instance=instance) - net_info = self._get_instance_nw_info(context, instance) + net_info = compute_utils.get_nw_info_for_instance(instance) if ((expect_running and FLAGS.resume_guests_state_on_host_boot) or FLAGS.start_guests_on_host_boot): LOG.info(_('Rebooting instance after nova-compute restart.'), diff --git a/nova/compute/utils.py b/nova/compute/utils.py index f63203a1a..67a174f51 100644 --- a/nova/compute/utils.py +++ b/nova/compute/utils.py @@ -19,6 +19,7 @@ from nova import db from nova import flags from nova import log +from nova.network import model as network_model from nova import notifications from nova.notifier import api as notifier_api @@ -100,3 +101,9 @@ def notify_about_instance_usage(context, instance, event_suffix, notifier_api.notify(context, 'compute.%s' % host, 'compute.instance.%s' % event_suffix, notifier_api.INFO, usage_info) + + +def get_nw_info_for_instance(instance): + info_cache = instance['info_cache'] or {} + cached_nwinfo = info_cache.get('network_info') or [] + return network_model.NetworkInfo.hydrate(cached_nwinfo) -- cgit