Skip to content

Commit 9a27434

Browse files
committed
Revert "Limit nodes by ironic shard key"
This reverts commit f5a12f5. Change-Id: I4a329237231ba741b57b2ef6437fcee226915d40
1 parent 3491b94 commit 9a27434

File tree

6 files changed

+19
-152
lines changed

6 files changed

+19
-152
lines changed

nova/conf/ironic.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,6 @@
8282
'service. Note that setting this to the empty string (``""``) '
8383
'will match the default conductor group, and is different than '
8484
'leaving the option unset.'),
85-
cfg.StrOpt(
86-
'shard',
87-
default=None,
88-
mutable=True,
89-
max_length=255,
90-
regex=r'^[a-zA-Z0-9_.-]*$',
91-
help='Specify which ironic shard this nova-compute will manage. '
92-
'This allows you to shard Ironic nodes between compute '
93-
'services across conductors and conductor groups. '
94-
'When a shard is set, the peer_list configuraton is ignored. '
95-
'We require that there is at most one nova-compute service '
96-
'for each shard.'),
9785
cfg.ListOpt(
9886
'peer_list',
9987
deprecated_for_removal=True,

nova/tests/unit/virt/ironic/test_client_wrapper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test__get_client_session(self, mock_ir_cli, mock_session):
8686
expected = {'session': 'session',
8787
'max_retries': CONF.ironic.api_max_retries,
8888
'retry_interval': CONF.ironic.api_retry_interval,
89-
'os_ironic_api_version': ['1.82', '1.38'],
89+
'os_ironic_api_version': ['1.46', '1.38'],
9090
'endpoint':
9191
self.get_ksa_adapter.return_value.get_endpoint.return_value,
9292
'interface': ['internal', 'public']}
@@ -111,7 +111,7 @@ def test__get_client_session_service_not_found(self, mock_ir_cli,
111111
expected = {'session': 'session',
112112
'max_retries': CONF.ironic.api_max_retries,
113113
'retry_interval': CONF.ironic.api_retry_interval,
114-
'os_ironic_api_version': ['1.82', '1.38'],
114+
'os_ironic_api_version': ['1.46', '1.38'],
115115
'endpoint': None,
116116
'region_name': CONF.ironic.region_name,
117117
'interface': ['internal', 'public']}
@@ -132,7 +132,7 @@ def test__get_client_and_valid_interfaces(self, mock_ir_cli, mock_session):
132132
expected = {'session': 'session',
133133
'max_retries': CONF.ironic.api_max_retries,
134134
'retry_interval': CONF.ironic.api_retry_interval,
135-
'os_ironic_api_version': ['1.82', '1.38'],
135+
'os_ironic_api_version': ['1.46', '1.38'],
136136
'endpoint': endpoint,
137137
'interface': ['admin']}
138138
mock_ir_cli.assert_called_once_with(1, **expected)

nova/tests/unit/virt/ironic/test_driver.py

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,31 +3020,6 @@ def test__refresh_hash_ring_peer_list(self, mock_can_send):
30203020
uncalled=['host3'])
30213021
mock_can_send.assert_called_once_with(min_version='1.46')
30223022

3023-
@mock.patch.object(ironic_driver.IronicDriver, '_can_send_version')
3024-
def test__refresh_hash_ring_peer_list_shard(self, mock_can_send):
3025-
services = ['host1', 'host2', 'host3']
3026-
expected_hosts = {'host1'}
3027-
self.mock_is_up.return_value = True
3028-
self.flags(host='host1')
3029-
self.flags(shard='shard1', group='ironic')
3030-
self._test__refresh_hash_ring(services, expected_hosts,
3031-
uncalled=['host2', 'host3'])
3032-
mock_can_send.assert_not_called()
3033-
3034-
@mock.patch.object(ironic_driver.IronicDriver, '_can_send_version')
3035-
def test__refresh_hash_ring_peer_list_shard_and_cg(self, mock_can_send):
3036-
services = ['host1', 'host2', 'host3']
3037-
expected_hosts = {'host1'}
3038-
self.mock_is_up.return_value = True
3039-
self.flags(host='host1')
3040-
self.flags(shard='shard1', group='ironic')
3041-
self.flags(conductor_group='not-none', group='ironic')
3042-
# Note that this is getting ignored, because the shard is set
3043-
self.flags(peer_list=['host1', 'host2'], group='ironic')
3044-
self._test__refresh_hash_ring(services, expected_hosts,
3045-
uncalled=['host2', 'host3'])
3046-
mock_can_send.assert_not_called()
3047-
30483023
@mock.patch.object(ironic_driver.IronicDriver, '_can_send_version')
30493024
def test__refresh_hash_ring_peer_list_old_api(self, mock_can_send):
30503025
mock_can_send.side_effect = (
@@ -3119,8 +3094,7 @@ def setUp(self, mock_services):
31193094
def _test__refresh_cache(self, instances, nodes, hosts, mock_instances,
31203095
mock_nodes, mock_hosts, mock_hash_ring,
31213096
mock_can_send, partition_key=None,
3122-
can_send_146=True, shard=None,
3123-
can_send_182=True):
3097+
can_send_146=True):
31243098
mock_instances.return_value = instances
31253099
mock_nodes.return_value = nodes
31263100
mock_hosts.side_effect = hosts
@@ -3130,18 +3104,12 @@ def _test__refresh_cache(self, instances, nodes, hosts, mock_instances,
31303104
if not can_send_146:
31313105
mock_can_send.side_effect = (
31323106
exception.IronicAPIVersionNotAvailable(version='1.46'))
3133-
if not can_send_182:
3134-
mock_can_send.side_effect = None, (
3135-
exception.IronicAPIVersionNotAvailable(version='1.82'))
3136-
31373107
self.driver.node_cache = {}
31383108
self.driver.node_cache_time = None
31393109

31403110
kwargs = {}
31413111
if partition_key is not None and can_send_146:
31423112
kwargs['conductor_group'] = partition_key
3143-
if shard and can_send_182:
3144-
kwargs["shard"] = shard
31453113

31463114
self.driver._refresh_cache()
31473115

@@ -3219,74 +3187,6 @@ def test__refresh_cache_partition_key(self):
32193187
expected_cache = {n.uuid: n for n in nodes}
32203188
self.assertEqual(expected_cache, self.driver.node_cache)
32213189

3222-
def test__refresh_cache_shard(self):
3223-
# normal operation, one compute service
3224-
instances = []
3225-
nodes = [
3226-
_get_cached_node(
3227-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3228-
_get_cached_node(
3229-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3230-
_get_cached_node(
3231-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3232-
]
3233-
hosts = [self.host, self.host, self.host]
3234-
shard = "shard1"
3235-
self.flags(shard=shard, group='ironic')
3236-
3237-
self._test__refresh_cache(instances, nodes, hosts,
3238-
shard=shard)
3239-
3240-
expected_cache = {n.uuid: n for n in nodes}
3241-
self.assertEqual(expected_cache, self.driver.node_cache)
3242-
3243-
def test__refresh_cache_shard_and_conductor_group(self):
3244-
# normal operation, one compute service
3245-
instances = []
3246-
nodes = [
3247-
_get_cached_node(
3248-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3249-
_get_cached_node(
3250-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3251-
_get_cached_node(
3252-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3253-
]
3254-
hosts = [self.host, self.host, self.host]
3255-
shard = "shard1"
3256-
self.flags(shard=shard, group='ironic')
3257-
partition_key = 'some-group'
3258-
self.flags(conductor_group=partition_key, group='ironic')
3259-
3260-
self._test__refresh_cache(instances, nodes, hosts,
3261-
shard=shard, partition_key=partition_key)
3262-
3263-
expected_cache = {n.uuid: n for n in nodes}
3264-
self.assertEqual(expected_cache, self.driver.node_cache)
3265-
3266-
def test__refresh_cache_shard_and_conductor_group_skip_shard(self):
3267-
# normal operation, one compute service
3268-
instances = []
3269-
nodes = [
3270-
_get_cached_node(
3271-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3272-
_get_cached_node(
3273-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3274-
_get_cached_node(
3275-
uuid=uuidutils.generate_uuid(), instance_uuid=None),
3276-
]
3277-
hosts = [self.host, self.host, self.host]
3278-
shard = "shard1"
3279-
self.flags(shard=shard, group='ironic')
3280-
partition_key = 'some-group'
3281-
self.flags(conductor_group=partition_key, group='ironic')
3282-
3283-
self._test__refresh_cache(instances, nodes, hosts,
3284-
shard=shard, partition_key=partition_key,
3285-
can_send_182=False)
3286-
3287-
expected_cache = {n.uuid: n for n in nodes}
3288-
self.assertEqual(expected_cache, self.driver.node_cache)
3289-
32903190
def test__refresh_cache_partition_key_old_api(self):
32913191
# normal operation, one compute service
32923192
instances = []

nova/virt/ironic/client_wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
IRONIC_GROUP = nova.conf.ironic.ironic_group
3333

3434
# The API version required by the Ironic driver
35-
IRONIC_API_VERSION = (1, 82)
35+
IRONIC_API_VERSION = (1, 46)
3636
# NOTE(TheJulia): This version should ALWAYS be the _last_ release
3737
# supported version of the API version used by nova. If a feature
3838
# needs a higher version to be negotiated to operate properly, then the version

nova/virt/ironic/driver.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -702,17 +702,11 @@ def node_is_available(self, nodename):
702702

703703
def _refresh_hash_ring(self, ctxt):
704704
peer_list = None
705-
if CONF.ironic.shard is not None:
706-
# When requesting a shard, we assume each compute service is
707-
# targeting a separate shard, so hard code peer_list to
708-
# just this service
709-
peer_list = set([CONF.host])
710-
711705
# NOTE(jroll) if this is set, we need to limit the set of other
712706
# compute services in the hash ring to hosts that are currently up
713707
# and specified in the peer_list config option, as there's no way
714708
# to check which conductor_group other compute services are using.
715-
if peer_list is None and CONF.ironic.conductor_group is not None:
709+
if CONF.ironic.conductor_group is not None:
716710
try:
717711
# NOTE(jroll) first we need to make sure the Ironic API can
718712
# filter by conductor_group. If it cannot, limiting to
@@ -775,24 +769,21 @@ def _get_node_list(**kwargs):
775769
# attribute. If the API isn't new enough to support conductor groups,
776770
# we fall back to managing all nodes. If it is new enough, we can
777771
# filter it in the API.
778-
# NOTE(johngarbutt) similarly, if shard is set, we also limit the
779-
# nodes that are returned by the shard key
780772
conductor_group = CONF.ironic.conductor_group
781-
shard = CONF.ironic.shard
782-
kwargs = {}
783-
try:
784-
if conductor_group is not None:
773+
if conductor_group is not None:
774+
try:
785775
self._can_send_version(min_version='1.46')
786-
kwargs['conductor_group'] = conductor_group
787-
if shard is not None:
788-
self._can_send_version(min_version='1.82')
789-
kwargs['shard'] = shard
790-
nodes = _get_node_list(**kwargs)
791-
except exception.IronicAPIVersionNotAvailable:
792-
LOG.error('Required Ironic API version is not '
793-
'available to filter nodes by conductor group '
794-
'and shard.')
795-
nodes = _get_node_list(**kwargs)
776+
nodes = _get_node_list(conductor_group=conductor_group)
777+
LOG.debug('Limiting manageable ironic nodes to conductor '
778+
'group %s', conductor_group)
779+
except exception.IronicAPIVersionNotAvailable:
780+
LOG.error('Required Ironic API version 1.46 is not '
781+
'available to filter nodes by conductor group. '
782+
'All nodes will be eligible to be managed by '
783+
'this compute service.')
784+
nodes = _get_node_list()
785+
else:
786+
nodes = _get_node_list()
796787

797788
# NOTE(saga): As _get_node_list() will take a long
798789
# time to return in large clusters we need to call it before

releasenotes/notes/ironic-shards-5641e4b1ab5bb7aa.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)