summaryrefslogtreecommitdiff
path: root/ironic/conductor/rpcapi.py
diff options
context:
space:
mode:
authorJim Rollenhagen <jim@jimrollenhagen.com>2018-07-02 20:44:32 +0000
committerJim Rollenhagen <jim@jimrollenhagen.com>2018-07-23 20:51:31 +0000
commit26fd55f7da2860d7fa71c8bbeabde72e0a74049a (patch)
tree4758924266ce0b228aac8c5eb497b595f2861260 /ironic/conductor/rpcapi.py
parent3b7e7fb3fcb24726b94d1bf1c44dc710fde0e996 (diff)
downloadironic-26fd55f7da2860d7fa71c8bbeabde72e0a74049a.tar.gz
Use conductor group for hash ring calculations
This changes the calculation for keys in the hash ring manager to be of the form "<conductor_group>:<driver>", instead of just driver. This is used when the RPC version pin is 1.47 or greater (1.47 was created to handle this). When finding an RPC topic, we use the conductor group marked on the node as part of this calculation. However, this becomes a problem when we don't have a node that we're looking up a topic for. In this case we look for a conductor in any group which has the driver loaded, and use a temporary hash ring that does not use conductor groups to find a conductor. This also begins the API work, as the API must be aware of the new hash ring calculation. However, exposing the conductor_group field and adding a microversion is left for a future patch. Story: 2001795 Task: 22641 Change-Id: Iaf71348666b683518fc6ce4769112459d98938f2
Diffstat (limited to 'ironic/conductor/rpcapi.py')
-rw-r--r--ironic/conductor/rpcapi.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/ironic/conductor/rpcapi.py b/ironic/conductor/rpcapi.py
index b644d8566..95f6445a5 100644
--- a/ironic/conductor/rpcapi.py
+++ b/ironic/conductor/rpcapi.py
@@ -95,13 +95,14 @@ class ConductorAPI(object):
| 1.44 - Added add_node_traits and remove_node_traits.
| 1.45 - Added continue_node_deploy
| 1.46 - Added reset_interfaces to update_node
+ | 1.47 - Added support for conductor groups
"""
# NOTE(rloo): This must be in sync with manager.ConductorManager's.
# NOTE(pas-ha): This also must be in sync with
# ironic.common.release_mappings.RELEASE_MAPPING['master']
- RPC_API_VERSION = '1.46'
+ RPC_API_VERSION = '1.47'
def __init__(self, topic=None):
super(ConductorAPI, self).__init__()
@@ -117,8 +118,10 @@ class ConductorAPI(object):
else self.RPC_API_VERSION)
self.client = rpc.get_client(target, version_cap=version_cap,
serializer=serializer)
+
+ use_groups = self.client.can_send_version('1.47')
# NOTE(deva): this is going to be buggy
- self.ring_manager = hash_ring.HashRingManager()
+ self.ring_manager = hash_ring.HashRingManager(use_groups=use_groups)
def get_topic_for(self, node):
"""Get the RPC topic for the conductor service the node is mapped to.
@@ -135,13 +138,15 @@ class ConductorAPI(object):
raise exception.TemporaryFailure()
try:
- ring = self.ring_manager[node.driver]
+ ring = self.ring_manager.get_ring(node.driver,
+ node.conductor_group)
dest = ring.get_nodes(node.uuid.encode('utf-8'),
replicas=CONF.hash_distribution_replicas)
return '%s.%s' % (self.topic, dest.pop())
except exception.DriverNotFound:
reason = (_('No conductor service registered which supports '
- 'driver %s.') % node.driver)
+ 'driver %(driver)s for conductor group "%(group)s".') %
+ {'driver': node.driver, 'group': node.conductor_group})
raise exception.NoValidHost(reason=reason)
def get_topic_for_driver(self, driver_name):
@@ -156,9 +161,12 @@ class ConductorAPI(object):
:raises: DriverNotFound
"""
- self.ring_manager.reset()
-
- ring = self.ring_manager[driver_name]
+ # NOTE(jroll) we want to be able to route this to any conductor,
+ # regardless of groupings. We use a fresh, uncached hash ring that
+ # does not take groups into account.
+ local_ring_manager = hash_ring.HashRingManager(use_groups=False,
+ cache=False)
+ ring = local_ring_manager.get_ring(driver_name, '')
host = random.choice(list(ring.nodes))
return self.topic + "." + host