diff options
| author | Andrew Laski <andrew.laski@rackspace.com> | 2013-02-21 17:30:06 -0500 |
|---|---|---|
| committer | Andrew Laski <andrew.laski@rackspace.com> | 2013-02-25 19:33:02 -0500 |
| commit | ab2920726c0e2633c033a31a324f30a97fdce6bd (patch) | |
| tree | 2c93e8a84654049f3420b19a537a0bd392f68001 /nova/cells | |
| parent | 73a58f9cc85bf8d7fc745d4260577d764e8bc81c (diff) | |
| download | nova-ab2920726c0e2633c033a31a324f30a97fdce6bd.tar.gz nova-ab2920726c0e2633c033a31a324f30a97fdce6bd.tar.xz nova-ab2920726c0e2633c033a31a324f30a97fdce6bd.zip | |
Rework instance actions to work with cells
In a cells setup an instance action is recorded at the global cell level
while events try to get recorded in a child cell compute node or
scheduler. The event recording fails because it can't find an action to
link to. This patch adds the recording of actions at the child cell
level, and changes the API extension to query the db in a child cell for
the record of actions and events.
This does not address the fact that an action is recorded at the global
cell level.
Bug 1132935
Change-Id: I5831f146397e7afa2d93d26c5d6f9abb9bc6670d
Diffstat (limited to 'nova/cells')
| -rw-r--r-- | nova/cells/manager.py | 18 | ||||
| -rw-r--r-- | nova/cells/messaging.py | 36 | ||||
| -rw-r--r-- | nova/cells/rpcapi.py | 28 | ||||
| -rw-r--r-- | nova/cells/scheduler.py | 11 |
4 files changed, 92 insertions, 1 deletions
diff --git a/nova/cells/manager.py b/nova/cells/manager.py index 55b3dadf7..ec4bc447f 100644 --- a/nova/cells/manager.py +++ b/nova/cells/manager.py @@ -66,7 +66,7 @@ class CellsManager(manager.Manager): Scheduling requests get passed to the scheduler class. """ - RPC_API_VERSION = '1.4' + RPC_API_VERSION = '1.5' def __init__(self, *args, **kwargs): # Mostly for tests. @@ -332,3 +332,19 @@ class CellsManager(manager.Manager): totals.setdefault(key, 0) totals[key] += val return totals + + def actions_get(self, ctxt, cell_name, instance_uuid): + response = self.msg_runner.actions_get(ctxt, cell_name, instance_uuid) + return response.value_or_raise() + + def action_get_by_request_id(self, ctxt, cell_name, instance_uuid, + request_id): + response = self.msg_runner.action_get_by_request_id(ctxt, cell_name, + instance_uuid, + request_id) + return response.value_or_raise() + + def action_events_get(self, ctxt, cell_name, action_id): + response = self.msg_runner.action_events_get(ctxt, cell_name, + action_id) + return response.value_or_raise() diff --git a/nova/cells/messaging.py b/nova/cells/messaging.py index 50a673464..db49cc8fd 100644 --- a/nova/cells/messaging.py +++ b/nova/cells/messaging.py @@ -717,6 +717,19 @@ class _TargetedMessageMethods(_BaseMessageMethods): compute_id) return jsonutils.to_primitive(compute_node) + def actions_get(self, message, instance_uuid): + actions = self.db.actions_get(message.ctxt, instance_uuid) + return jsonutils.to_primitive(actions) + + def action_get_by_request_id(self, message, instance_uuid, request_id): + action = self.db.action_get_by_request_id(message.ctxt, instance_uuid, + request_id) + return jsonutils.to_primitive(action) + + def action_events_get(self, message, action_id): + action_events = self.db.action_events_get(message.ctxt, action_id) + return jsonutils.to_primitive(action_events) + class _BroadcastMessageMethods(_BaseMessageMethods): """These are the methods that can be called as a part of a broadcast @@ -1183,6 +1196,29 @@ class MessageRunner(object): cell_name, need_response=True) return message.process() + def actions_get(self, ctxt, cell_name, instance_uuid): + method_kwargs = dict(instance_uuid=instance_uuid) + message = _TargetedMessage(self, ctxt, 'actions_get', + method_kwargs, 'down', + cell_name, need_response=True) + return message.process() + + def action_get_by_request_id(self, ctxt, cell_name, instance_uuid, + request_id): + method_kwargs = dict(instance_uuid=instance_uuid, + request_id=request_id) + message = _TargetedMessage(self, ctxt, 'action_get_by_request_id', + method_kwargs, 'down', + cell_name, need_response=True) + return message.process() + + def action_events_get(self, ctxt, cell_name, action_id): + method_kwargs = dict(action_id=action_id) + message = _TargetedMessage(self, ctxt, 'action_events_get', + method_kwargs, 'down', + cell_name, need_response=True) + return message.process() + @staticmethod def get_message_types(): return _CELL_MESSAGE_TYPE_TO_MESSAGE_CLS.keys() diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py index 910c4ab9d..be45e8f03 100644 --- a/nova/cells/rpcapi.py +++ b/nova/cells/rpcapi.py @@ -24,6 +24,7 @@ messging module. from oslo.config import cfg +from nova import exception from nova.openstack.common import jsonutils from nova.openstack.common import log as logging from nova.openstack.common.rpc import proxy as rpc_proxy @@ -47,6 +48,8 @@ class CellsAPI(rpc_proxy.RpcProxy): 1.3 - Adds task_log_get_all() 1.4 - Adds compute_node_get(), compute_node_get_all(), and compute_node_stats() + 1.5 - Adds actions_get(), action_get_by_request_id(), and + action_events_get() ''' BASE_RPC_API_VERSION = '1.0' @@ -219,3 +222,28 @@ class CellsAPI(rpc_proxy.RpcProxy): """Return compute node stats from all cells.""" return self.call(ctxt, self.make_msg('compute_node_stats'), version='1.4') + + def actions_get(self, ctxt, instance): + if not instance['cell_name']: + raise exception.InstanceUnknownCell(instance_uuid=instance['uuid']) + return self.call(ctxt, self.make_msg('actions_get', + cell_name=instance['cell_name'], + instance_uuid=instance['uuid']), + version='1.5') + + def action_get_by_request_id(self, ctxt, instance, request_id): + if not instance['cell_name']: + raise exception.InstanceUnknownCell(instance_uuid=instance['uuid']) + return self.call(ctxt, self.make_msg('action_get_by_request_id', + cell_name=instance['cell_name'], + instance_uuid=instance['uuid'], + request_id=request_id), + version='1.5') + + def action_events_get(self, ctxt, instance, action_id): + if not instance['cell_name']: + raise exception.InstanceUnknownCell(instance_uuid=instance['uuid']) + return self.call(ctxt, self.make_msg('action_events_get', + cell_name=instance['cell_name'], + action_id=action_id), + version='1.5') diff --git a/nova/cells/scheduler.py b/nova/cells/scheduler.py index 3b69b2eac..8ec65b2d0 100644 --- a/nova/cells/scheduler.py +++ b/nova/cells/scheduler.py @@ -22,6 +22,8 @@ import time from oslo.config import cfg from nova import compute +from nova.compute import instance_actions +from nova.compute import utils as compute_utils from nova.compute import vm_states from nova.db import base from nova import exception @@ -70,6 +72,12 @@ class CellsScheduler(base.Base): self.msg_runner.instance_update_at_top(ctxt, instance) + def _create_action_here(self, ctxt, instance_uuids): + for instance_uuid in instance_uuids: + action = compute_utils.pack_action_start(ctxt, instance_uuid, + instance_actions.CREATE) + self.db.action_start(ctxt, action) + def _get_possible_cells(self): cells = set(self.state_manager.get_child_cells()) our_cell = self.state_manager.get_my_state() @@ -102,6 +110,9 @@ class CellsScheduler(base.Base): # Need to create instance DB entries as the host scheduler # expects that the instance(s) already exists. self._create_instances_here(ctxt, request_spec) + # Need to record the create action in the db as the scheduler + # expects it to already exist. + self._create_action_here(ctxt, request_spec['instance_uuids']) self.scheduler_rpcapi.run_instance(ctxt, **host_sched_kwargs) return |
