Add SIGHUP handlers for compute rpcapi to console and conductor
This adds SIGHUP handlers to console, consoleauth, and conductor services to reload the compute_rpcapi. This is required for auto version pinning to be dynamic at runtime. Related to blueprint service-version-behavior Change-Id: I83a25bda681daa249ffca8bc1f38edcd70dd7cc5
This commit is contained in:
parent
242ee4b5e7
commit
a14ec9182b
|
@ -32,7 +32,7 @@ from nova.conductor.tasks import live_migrate
|
|||
from nova.conductor.tasks import migrate
|
||||
from nova.db import base
|
||||
from nova import exception
|
||||
from nova.i18n import _, _LE, _LW
|
||||
from nova.i18n import _, _LE, _LI, _LW
|
||||
from nova import image
|
||||
from nova import manager
|
||||
from nova import objects
|
||||
|
@ -151,6 +151,11 @@ class ComputeTaskManager(base.Base):
|
|||
self.scheduler_client = scheduler_client.SchedulerClient()
|
||||
self.notifier = rpc.get_notifier('compute', CONF.host)
|
||||
|
||||
def reset(self):
|
||||
LOG.info(_LI('Reloading compute RPC API'))
|
||||
compute_rpcapi.LAST_VERSION = None
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
|
||||
@messaging.expected_exceptions(exception.NoValidHost,
|
||||
exception.ComputeServiceUnavailable,
|
||||
exception.InvalidHypervisorType,
|
||||
|
|
|
@ -24,6 +24,7 @@ from oslo_utils import importutils
|
|||
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova import exception
|
||||
from nova.i18n import _LI
|
||||
from nova import manager
|
||||
from nova import utils
|
||||
|
||||
|
@ -63,6 +64,11 @@ class ConsoleProxyManager(manager.Manager):
|
|||
self.driver.host = self.host
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
|
||||
def reset(self):
|
||||
LOG.info(_LI('Reloading compute RPC API'))
|
||||
compute_rpcapi.LAST_VERSION = None
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
|
||||
def init_host(self):
|
||||
self.driver.init_host()
|
||||
|
||||
|
|
|
@ -56,6 +56,11 @@ class ConsoleAuthManager(manager.Manager):
|
|||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.cells_rpcapi = cells_rpcapi.CellsAPI()
|
||||
|
||||
def reset(self):
|
||||
LOG.info(_LI('Reloading compute RPC API'))
|
||||
compute_rpcapi.LAST_VERSION = None
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
|
||||
def _get_tokens_for_instance(self, instance_uuid):
|
||||
tokens_str = self.mc.get(instance_uuid.encode('UTF-8'))
|
||||
if not tokens_str:
|
||||
|
|
|
@ -908,6 +908,14 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
|
|||
self.conductor = conductor_manager.ComputeTaskManager()
|
||||
self.conductor_manager = self.conductor
|
||||
|
||||
def test_reset(self):
|
||||
with mock.patch('nova.compute.rpcapi.ComputeAPI') as mock_rpc:
|
||||
old_rpcapi = self.conductor_manager.compute_rpcapi
|
||||
self.conductor_manager.reset()
|
||||
mock_rpc.assert_called_once_with()
|
||||
self.assertNotEqual(old_rpcapi,
|
||||
self.conductor_manager.compute_rpcapi)
|
||||
|
||||
def test_migrate_server_fails_with_rebuild(self):
|
||||
self.assertRaises(NotImplementedError, self.conductor.migrate_server,
|
||||
self.context, None, None, True, True, None, None, None)
|
||||
|
|
|
@ -46,6 +46,14 @@ class ConsoleTestCase(test.TestCase):
|
|||
self.context = context.RequestContext(self.user_id, self.project_id)
|
||||
self.host = 'test_compute_host'
|
||||
|
||||
def test_reset(self):
|
||||
with mock.patch('nova.compute.rpcapi.ComputeAPI') as mock_rpc:
|
||||
old_rpcapi = self.console.compute_rpcapi
|
||||
self.console.reset()
|
||||
mock_rpc.assert_called_once_with()
|
||||
self.assertNotEqual(old_rpcapi,
|
||||
self.console.compute_rpcapi)
|
||||
|
||||
def _create_instance(self):
|
||||
"""Create a test instance."""
|
||||
inst = {}
|
||||
|
|
|
@ -36,6 +36,14 @@ class ConsoleauthTestCase(test.NoDBTestCase):
|
|||
self.context = context.get_admin_context()
|
||||
self.instance_uuid = '00000000-0000-0000-0000-000000000000'
|
||||
|
||||
def test_reset(self):
|
||||
with mock.patch('nova.compute.rpcapi.ComputeAPI') as mock_rpc:
|
||||
old_rpcapi = self.manager_api.compute_rpcapi
|
||||
self.manager_api.reset()
|
||||
mock_rpc.assert_called_once_with()
|
||||
self.assertNotEqual(old_rpcapi,
|
||||
self.manager_api.compute_rpcapi)
|
||||
|
||||
@mock.patch('nova.objects.instance.Instance.get_by_uuid')
|
||||
def test_tokens_expire(self, mock_get):
|
||||
mock_get.return_value = None
|
||||
|
|
Loading…
Reference in New Issue