diff options
author | Jim Rollenhagen <jim@jimrollenhagen.com> | 2018-07-02 20:44:32 +0000 |
---|---|---|
committer | Jim Rollenhagen <jim@jimrollenhagen.com> | 2018-07-23 20:51:31 +0000 |
commit | 26fd55f7da2860d7fa71c8bbeabde72e0a74049a (patch) | |
tree | 4758924266ce0b228aac8c5eb497b595f2861260 /ironic/db | |
parent | 3b7e7fb3fcb24726b94d1bf1c44dc710fde0e996 (diff) | |
download | ironic-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/db')
-rw-r--r-- | ironic/db/api.py | 3 | ||||
-rw-r--r-- | ironic/db/sqlalchemy/api.py | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/ironic/db/api.py b/ironic/db/api.py index c7be8258d..28e0f10f3 100644 --- a/ironic/db/api.py +++ b/ironic/db/api.py @@ -518,9 +518,10 @@ class Connection(object): """ @abc.abstractmethod - def get_active_hardware_type_dict(self): + def get_active_hardware_type_dict(self, use_groups=False): """Retrieve hardware types for the registered and active conductors. + :param use_groups: Whether to factor conductor_group into the keys. :returns: A dict which maps hardware type names to the set of hosts which support them. For example: diff --git a/ironic/db/sqlalchemy/api.py b/ironic/db/sqlalchemy/api.py index bcc22a527..9e3c9918c 100644 --- a/ironic/db/sqlalchemy/api.py +++ b/ironic/db/sqlalchemy/api.py @@ -855,7 +855,7 @@ class Connection(api.Connection): 'powering process, their power state can be incorrect: ' '%(nodes)s', {'nodes': nodes}) - def get_active_hardware_type_dict(self): + def get_active_hardware_type_dict(self, use_groups=False): query = (model_query(models.ConductorHardwareInterfaces, models.Conductor) .join(models.Conductor)) @@ -863,7 +863,12 @@ class Connection(api.Connection): d2c = collections.defaultdict(set) for iface_row, cdr_row in result: - d2c[iface_row['hardware_type']].add(cdr_row['hostname']) + hw_type = iface_row['hardware_type'] + if use_groups: + key = '%s:%s' % (cdr_row['conductor_group'], hw_type) + else: + key = hw_type + d2c[key].add(cdr_row['hostname']) return d2c def get_offline_conductors(self): |