summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2013-06-10 21:18:37 -0400
committerRussell Bryant <rbryant@redhat.com>2013-06-14 11:38:22 -0400
commit2bcdb2057188a1a1bd1731ff713631e8a30e4f20 (patch)
tree774f85092371effcef463ff92fd17b3f1bf5a411
parent77595f8e08a61507ad5c7c990651fd4f8131c150 (diff)
downloadnova-2bcdb2057188a1a1bd1731ff713631e8a30e4f20.tar.gz
nova-2bcdb2057188a1a1bd1731ff713631e8a30e4f20.tar.xz
nova-2bcdb2057188a1a1bd1731ff713631e8a30e4f20.zip
Add rpc client side version control.
This is a first pass at client side version control for rpc. It allows you to configure a max version of messages that clients are allowed to send. You can find one example of how clients need to adapt in the conductor rpcapi. All other changes in rpc apis since the grizzly release are not applicable to this. Some future improvements to this could be reporting the versions supported by running services and having that be discoverable via the API. We could also consider allow setting these client side version caps via the API. For now, recommended values for these config options while attempting a rolling upgrade will just have to be documented. The config options allow specifying specific rpc api version numbers if desired, but an alias of 'grizzly' is also supported. So typically at the start of a rolling upgrade you'd have: [upgrade_levels] compute=grizzly conductor=grizzly scheduler=grizzly ... etc ... And as you update all instances of a service, you would remove that bit from your configuration across the deployment using your config management system of choice. DocImpact Implements blueprint rpc-version-control. Change-Id: I2c0fd6dd7484c87823846d7c31d6525d93cd1b43
-rw-r--r--nova/baserpc.py18
-rw-r--r--nova/cells/rpc_driver.py19
-rw-r--r--nova/cells/rpcapi.py19
-rw-r--r--nova/cert/rpcapi.py18
-rw-r--r--nova/compute/rpcapi.py19
-rw-r--r--nova/conductor/rpcapi.py33
-rw-r--r--nova/console/rpcapi.py18
-rw-r--r--nova/consoleauth/rpcapi.py18
-rw-r--r--nova/network/rpcapi.py18
-rw-r--r--nova/scheduler/rpcapi.py18
10 files changed, 184 insertions, 14 deletions
diff --git a/nova/baserpc.py b/nova/baserpc.py
index 1cb474209..b166cb400 100644
--- a/nova/baserpc.py
+++ b/nova/baserpc.py
@@ -18,11 +18,20 @@
Base RPC client and server common to all services.
"""
+from oslo.config import cfg
+
from nova.openstack.common import jsonutils
from nova.openstack.common import rpc
import nova.openstack.common.rpc.proxy as rpc_proxy
+CONF = cfg.CONF
+rpcapi_cap_opt = cfg.StrOpt('baseapi',
+ default=None,
+ help='Set a version cap for messages sent to the base api in any '
+ 'service')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
_NAMESPACE = 'baseapi'
@@ -45,9 +54,16 @@ class BaseAPI(rpc_proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ # baseapi was added in havana
+ }
+
def __init__(self, topic):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.baseapi,
+ CONF.upgrade_levels.baseapi)
super(BaseAPI, self).__init__(topic=topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
self.namespace = _NAMESPACE
def ping(self, context, arg, timeout=None):
diff --git a/nova/cells/rpc_driver.py b/nova/cells/rpc_driver.py
index 0dcf1184c..6b11e0f05 100644
--- a/nova/cells/rpc_driver.py
+++ b/nova/cells/rpc_driver.py
@@ -34,6 +34,11 @@ CONF = cfg.CONF
CONF.register_opts(cell_rpc_driver_opts, group='cells')
CONF.import_opt('call_timeout', 'nova.cells.opts', group='cells')
+rpcapi_cap_opt = cfg.StrOpt('intercell',
+ default=None,
+ help='Set a version cap for messages sent between cells services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
_CELL_TO_CELL_RPC_API_VERSION = '1.0'
@@ -103,9 +108,21 @@ class InterCellRPCAPI(rpc_proxy.RpcProxy):
API version history:
1.0 - Initial version.
+
+ ... Grizzly supports message version 1.0. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.0.
"""
+
+ VERSION_ALIASES = {
+ 'grizzly': '1.0',
+ }
+
def __init__(self, default_version):
- super(InterCellRPCAPI, self).__init__(None, default_version)
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.intercell,
+ CONF.upgrade_levels.intercell)
+ super(InterCellRPCAPI, self).__init__(None, default_version,
+ version_cap=version_cap)
@staticmethod
def _get_server_params_for_cell(next_hop):
diff --git a/nova/cells/rpcapi.py b/nova/cells/rpcapi.py
index 767498291..e65d8f490 100644
--- a/nova/cells/rpcapi.py
+++ b/nova/cells/rpcapi.py
@@ -33,6 +33,11 @@ CONF = cfg.CONF
CONF.import_opt('enable', 'nova.cells.opts', group='cells')
CONF.import_opt('topic', 'nova.cells.opts', group='cells')
+rpcapi_cap_opt = cfg.StrOpt('cells',
+ default=None,
+ help='Set a version cap for messages sent to local cells services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class CellsAPI(rpc_proxy.RpcProxy):
'''Cells client-side RPC API
@@ -49,15 +54,27 @@ class CellsAPI(rpc_proxy.RpcProxy):
1.5 - Adds actions_get(), action_get_by_request_id(), and
action_events_get()
1.6 - Adds consoleauth_delete_tokens() and validate_console_port()
+
+ ... Grizzly supports message version 1.6. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.6.
+
1.7 - Adds service_update()
1.8 - Adds build_instances(), deprecates schedule_run_instance()
1.9 - Adds get_capacities()
'''
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ 'grizzly': '1.6'
+ }
+
def __init__(self):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.cells,
+ CONF.upgrade_levels.cells)
super(CellsAPI, self).__init__(topic=CONF.cells.topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
def cast_compute_api_method(self, ctxt, cell_name, method,
*args, **kwargs):
diff --git a/nova/cert/rpcapi.py b/nova/cert/rpcapi.py
index 505efe75f..f4311b517 100644
--- a/nova/cert/rpcapi.py
+++ b/nova/cert/rpcapi.py
@@ -31,6 +31,11 @@ rpcapi_opts = [
CONF = cfg.CONF
CONF.register_opts(rpcapi_opts)
+rpcapi_cap_opt = cfg.StrOpt('cert',
+ default=None,
+ help='Set a version cap for messages sent to cert services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class CertAPI(nova.openstack.common.rpc.proxy.RpcProxy):
'''Client side of the cert rpc API.
@@ -39,6 +44,10 @@ class CertAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.0 - Initial version.
1.1 - Added get_backdoor_port()
+
+ ... Grizzly supports message version 1.1. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.1.
'''
#
@@ -51,10 +60,17 @@ class CertAPI(nova.openstack.common.rpc.proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ 'grizzly': '1.1',
+ }
+
def __init__(self):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.cert,
+ CONF.upgrade_levels.cert)
super(CertAPI, self).__init__(
topic=CONF.cert_topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
def revoke_certs_by_user(self, ctxt, user_id):
return self.call(ctxt, self.make_msg('revoke_certs_by_user',
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index 98e90cf24..30db6010f 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -36,6 +36,11 @@ rpcapi_opts = [
CONF = cfg.CONF
CONF.register_opts(rpcapi_opts)
+rpcapi_cap_opt = cfg.StrOpt('compute',
+ default=None,
+ help='Set a version cap for messages sent to compute services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
def _compute_topic(topic, ctxt, host, instance):
'''Get the topic to use for a message.
@@ -167,6 +172,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
vnc on the correct port
2.27 - Adds 'reservations' to terminate_instance() and
soft_delete_instance()
+
+ ... Grizzly supports message version 2.27. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 2.27.
+
2.28 - Adds check_instance_shared_storage()
2.29 - Made start_instance() and stop_instance() take new-world
instance objects
@@ -182,11 +192,18 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '2.0'
+ VERSION_ALIASES = {
+ 'grizzly': '2.27',
+ }
+
def __init__(self):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.compute,
+ CONF.upgrade_levels.compute)
super(ComputeAPI, self).__init__(
topic=CONF.compute_topic,
default_version=self.BASE_RPC_API_VERSION,
- serializer=objects_base.NovaObjectSerializer())
+ serializer=objects_base.NovaObjectSerializer(),
+ version_cap=version_cap)
def add_aggregate_host(self, ctxt, aggregate, host_param, host,
slave_info=None):
diff --git a/nova/conductor/rpcapi.py b/nova/conductor/rpcapi.py
index c9b1c0af7..bb66ca8b2 100644
--- a/nova/conductor/rpcapi.py
+++ b/nova/conductor/rpcapi.py
@@ -22,6 +22,11 @@ import nova.openstack.common.rpc.proxy
CONF = cfg.CONF
+rpcapi_cap_opt = cfg.StrOpt('conductor',
+ default=None,
+ help='Set a version cap for messages sent to conductor services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
"""Client side of the conductor RPC API
@@ -88,6 +93,11 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.47 - Added columns_to_join to instance_get_all_by_host and
instance_get_all_by_filters
1.48 - Added compute_unrescue
+
+ ... Grizzly supports message version 1.48. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.48.
+
1.49 - Added columns_to_join to instance_get_by_uuid
1.50 - Added object_action() and object_class_action()
1.51 - Added the 'legacy' argument to
@@ -96,11 +106,18 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ 'grizzly': '1.48',
+ }
+
def __init__(self):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.conductor,
+ CONF.upgrade_levels.conductor)
super(ConductorAPI, self).__init__(
topic=CONF.conductor.topic,
default_version=self.BASE_RPC_API_VERSION,
- serializer=objects_base.NovaObjectSerializer())
+ serializer=objects_base.NovaObjectSerializer(),
+ version_cap=version_cap)
def instance_update(self, context, instance_uuid, updates,
service=None):
@@ -119,10 +136,16 @@ class ConductorAPI(nova.openstack.common.rpc.proxy.RpcProxy):
def instance_get_by_uuid(self, context, instance_uuid,
columns_to_join=None):
- msg = self.make_msg('instance_get_by_uuid',
- instance_uuid=instance_uuid,
- columns_to_join=columns_to_join)
- return self.call(context, msg, version='1.49')
+ if self.can_send_version('1.49'):
+ version = '1.49'
+ msg = self.make_msg('instance_get_by_uuid',
+ instance_uuid=instance_uuid,
+ columns_to_join=columns_to_join)
+ else:
+ version = '1.2'
+ msg = self.make_msg('instance_get_by_uuid',
+ instance_uuid=instance_uuid)
+ return self.call(context, msg, version=version)
def migration_get(self, context, migration_id):
msg = self.make_msg('migration_get', migration_id=migration_id)
diff --git a/nova/console/rpcapi.py b/nova/console/rpcapi.py
index 86debae32..7a78b52c2 100644
--- a/nova/console/rpcapi.py
+++ b/nova/console/rpcapi.py
@@ -31,6 +31,11 @@ rpcapi_opts = [
CONF = cfg.CONF
CONF.register_opts(rpcapi_opts)
+rpcapi_cap_opt = cfg.StrOpt('console',
+ default=None,
+ help='Set a version cap for messages sent to console services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class ConsoleAPI(nova.openstack.common.rpc.proxy.RpcProxy):
'''Client side of the console rpc API.
@@ -39,6 +44,10 @@ class ConsoleAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.0 - Initial version.
1.1 - Added get_backdoor_port()
+
+ ... Grizzly supports message version 1.1. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.1.
'''
#
@@ -51,11 +60,18 @@ class ConsoleAPI(nova.openstack.common.rpc.proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ 'grizzly': '1.1',
+ }
+
def __init__(self, topic=None):
topic = topic if topic else CONF.console_topic
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.console,
+ CONF.upgrade_levels.console)
super(ConsoleAPI, self).__init__(
topic=topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
def add_console(self, ctxt, instance_id):
self.cast(ctxt, self.make_msg('add_console', instance_id=instance_id))
diff --git a/nova/consoleauth/rpcapi.py b/nova/consoleauth/rpcapi.py
index 62aeab8da..ffc1a3de4 100644
--- a/nova/consoleauth/rpcapi.py
+++ b/nova/consoleauth/rpcapi.py
@@ -24,6 +24,11 @@ import nova.openstack.common.rpc.proxy
CONF = cfg.CONF
+rpcapi_cap_opt = cfg.StrOpt('consoleauth',
+ default=None,
+ help='Set a version cap for messages sent to consoleauth services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class ConsoleAuthAPI(nova.openstack.common.rpc.proxy.RpcProxy):
'''Client side of the consoleauth rpc API.
@@ -34,6 +39,10 @@ class ConsoleAuthAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.1 - Added get_backdoor_port()
1.2 - Added instance_uuid to authorize_console, and
delete_tokens_for_instance
+
+ ... Grizzly supports message version 1.2. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.2.
'''
#
@@ -46,10 +55,17 @@ class ConsoleAuthAPI(nova.openstack.common.rpc.proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ 'grizzly': '1.2',
+ }
+
def __init__(self):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.consoleauth,
+ CONF.upgrade_levels.consoleauth)
super(ConsoleAuthAPI, self).__init__(
topic=CONF.consoleauth_topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
def authorize_console(self, ctxt, token, console_type, host, port,
internal_access_path, instance_uuid=None):
diff --git a/nova/network/rpcapi.py b/nova/network/rpcapi.py
index c335c9cb4..1fa5610ca 100644
--- a/nova/network/rpcapi.py
+++ b/nova/network/rpcapi.py
@@ -37,6 +37,11 @@ rpcapi_opts = [
CONF = cfg.CONF
CONF.register_opts(rpcapi_opts)
+rpcapi_cap_opt = cfg.StrOpt('network',
+ default=None,
+ help='Set a version cap for messages sent to network services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class NetworkAPI(rpc_proxy.RpcProxy):
'''Client side of the network rpc API.
@@ -54,6 +59,10 @@ class NetworkAPI(rpc_proxy.RpcProxy):
1.8 - Adds macs to allocate_for_instance
1.9 - Adds rxtx_factor to [add|remove]_fixed_ip, removes instance_uuid
from allocate_for_instance and instance_get_nw_info
+
+ ... Grizzly supports message version 1.9. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 1.9.
'''
#
@@ -66,11 +75,18 @@ class NetworkAPI(rpc_proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '1.0'
+ VERSION_ALIASES = {
+ 'grizzly': '1.9',
+ }
+
def __init__(self, topic=None):
topic = topic if topic else CONF.network_topic
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.network,
+ CONF.upgrade_levels.network)
super(NetworkAPI, self).__init__(
topic=topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
def get_all_networks(self, ctxt):
return self.call(ctxt, self.make_msg('get_all_networks'))
diff --git a/nova/scheduler/rpcapi.py b/nova/scheduler/rpcapi.py
index 2cfd5688f..369363bb4 100644
--- a/nova/scheduler/rpcapi.py
+++ b/nova/scheduler/rpcapi.py
@@ -32,6 +32,11 @@ rpcapi_opts = [
CONF = cfg.CONF
CONF.register_opts(rpcapi_opts)
+rpcapi_cap_opt = cfg.StrOpt('scheduler',
+ default=None,
+ help='Set a version cap for messages sent to scheduler services')
+CONF.register_opt(rpcapi_cap_opt, 'upgrade_levels')
+
class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
'''Client side of the scheduler rpc API.
@@ -58,6 +63,10 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
- accepts a list of capabilities
2.5 - Add get_backdoor_port()
2.6 - Add select_hosts()
+
+ ... Grizzly supports message version 2.6. So, any changes to existing
+ methods in 2.x after that point should be done such that they can
+ handle the version_cap being set to 2.6.
'''
#
@@ -70,9 +79,16 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
#
BASE_RPC_API_VERSION = '2.0'
+ VERSION_ALIASES = {
+ 'grizzly': '2.6',
+ }
+
def __init__(self):
+ version_cap = self.VERSION_ALIASES.get(CONF.upgrade_levels.scheduler,
+ CONF.upgrade_levels.scheduler)
super(SchedulerAPI, self).__init__(topic=CONF.scheduler_topic,
- default_version=self.BASE_RPC_API_VERSION)
+ default_version=self.BASE_RPC_API_VERSION,
+ version_cap=version_cap)
def run_instance(self, ctxt, request_spec, admin_password,
injected_files, requested_networks, is_first_time,