Skip to content

Commit ca44fe3

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Follow up for pre-filter-disabled-computes series"
2 parents 499e753 + 12a6fe5 commit ca44fe3

File tree

6 files changed

+37
-24
lines changed

6 files changed

+37
-24
lines changed

doc/source/admin/configuration/schedulers.rst

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,22 @@ Compute Disabled Status Support
8080

8181
Starting in the Train release, there is a mandatory `pre-filter
8282
<https://specs.openstack.org/openstack/nova-specs/specs/train/approved/pre-filter-disabled-computes.html>`_
83-
which will exclude disabled compute nodes similar to the `ComputeFilter`_.
84-
Compute node resource providers with the ``COMPUTE_STATUS_DISABLED`` trait will
85-
be excluded as scheduling candidates. The trait is managed by the
86-
``nova-compute`` service and should mirror the ``disabled`` status on the
87-
related compute service record in the `os-services`_ API. For example, if a
88-
compute service's status is ``disabled``, the related compute node resource
89-
provider(s) for that service should have the ``COMPUTE_STATUS_DISABLED`` trait.
90-
When the service status is ``enabled`` the ``COMPUTE_STATUS_DISABLED`` trait
91-
shall be removed.
83+
which will exclude disabled compute nodes similar to (but does not fully
84+
replace) the `ComputeFilter`_. Compute node resource providers with the
85+
``COMPUTE_STATUS_DISABLED`` trait will be excluded as scheduling candidates.
86+
The trait is managed by the ``nova-compute`` service and should mirror the
87+
``disabled`` status on the related compute service record in the
88+
`os-services`_ API. For example, if a compute service's status is ``disabled``,
89+
the related compute node resource provider(s) for that service should have the
90+
``COMPUTE_STATUS_DISABLED`` trait. When the service status is ``enabled`` the
91+
``COMPUTE_STATUS_DISABLED`` trait shall be removed.
9292

9393
If the compute service is down when the status is changed, the trait will be
94-
synchronized by the compute service when it is restarted.
94+
synchronized by the compute service when it is restarted. Similarly, if an
95+
error occurs when trying to add or remove the trait on a given resource
96+
provider, the trait will be synchronized when the ``update_available_resource``
97+
periodic task runs - which is controlled by the
98+
:oslo.config:option:`update_resources_interval` configuration option.
9599

96100
.. _os-services: https://developer.openstack.org/api-ref/compute/#compute-services-os-services
97101

nova/compute/api.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5086,10 +5086,12 @@ def _update_compute_provider_status(self, context, service):
50865086
'COMPUTE_STATUS_DISABLED trait.', service.host)
50875087
self.rpcapi.set_host_enabled(context, service.host, enabled)
50885088
except Exception:
5089-
LOG.exception('An error occurred while updating host enabled '
5090-
'status to "%s" for compute host: %s',
5091-
'enabled' if enabled else 'disabled',
5092-
service.host)
5089+
LOG.exception('An error occurred while updating the '
5090+
'COMPUTE_STATUS_DISABLED trait on compute node '
5091+
'resource providers managed by host %s. The trait '
5092+
'will be synchronized automatically by the compute '
5093+
'service when the update_available_resource '
5094+
'periodic task runs.', service.host)
50935095

50945096
def service_update(self, context, service):
50955097
"""Performs the actual service update operation.

nova/compute/manager.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5012,16 +5012,20 @@ def _update_compute_provider_status(self, context, enabled):
50125012
exception.ResourceProviderUpdateConflict,
50135013
exception.ResourceProviderUpdateFailed,
50145014
exception.TraitRetrievalFailed) as e:
5015-
# This is best effort so just log a warning and continue. The
5016-
# update_available_resource periodic task will sync the trait.
5015+
# This is best effort so just log a warning and continue.
50175016
LOG.warning('An error occurred while updating '
50185017
'COMPUTE_STATUS_DISABLED trait on compute node '
5019-
'resource provider %s. Error: %s',
5018+
'resource provider %s. The trait will be '
5019+
'synchronized when the update_available_resource '
5020+
'periodic task runs. Error: %s',
50205021
node.uuid, e.format_message())
50215022
except Exception:
50225023
LOG.exception('An error occurred while updating '
50235024
'COMPUTE_STATUS_DISABLED trait on compute node '
5024-
'resource provider %s.', node.uuid)
5025+
'resource provider %s. The trait will be '
5026+
'synchronized when the '
5027+
'update_available_resource periodic task runs.',
5028+
node.uuid)
50255029

50265030
@wrap_exception()
50275031
def set_host_enabled(self, context, enabled):

nova/tests/unit/compute/test_host_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,9 @@ def test_update_compute_provider_status_service_rpc_error(self, mock_she):
390390
service_is_up.assert_called_once_with(service)
391391
mock_she.assert_called_once_with(self.ctxt, 'fake-host', False)
392392
log_output = self.stdlog.logger.output
393-
self.assertIn('An error occurred while updating host enabled '
394-
'status to "disabled" for compute host: fake-host',
393+
self.assertIn('An error occurred while updating the '
394+
'COMPUTE_STATUS_DISABLED trait on compute node '
395+
'resource providers managed by host fake-host.',
395396
log_output)
396397
self.assertIn('MessagingTimeout', log_output)
397398

nova/tests/unit/compute/test_resource_tracker.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,8 @@ def test_existing_node_capabilities_as_traits(self, mock_sync_disabled):
14561456
@mock.patch('nova.compute.resource_tracker.ResourceTracker.'
14571457
'_sync_compute_service_disabled_trait')
14581458
@mock.patch('nova.objects.ComputeNode.save')
1459-
def test_existing_node_update_provider_tree_implemented(self, save_mock,
1460-
mock_sync_disable):
1459+
def test_existing_node_update_provider_tree_implemented(
1460+
self, save_mock, mock_sync_disabled):
14611461
"""The update_provider_tree() virt driver method is only implemented
14621462
for some virt drivers. This method returns inventory, trait, and
14631463
aggregate information for resource providers in a tree associated with
@@ -1540,7 +1540,7 @@ def fake_upt(ptree, nodename, allocations=None):
15401540
# 1024MB in GB
15411541
exp_inv[orc.DISK_GB]['reserved'] = 1
15421542
self.assertEqual(exp_inv, ptree.data(new_compute.uuid).inventory)
1543-
mock_sync_disable.assert_called_once()
1543+
mock_sync_disabled.assert_called_once()
15441544

15451545
@mock.patch('nova.compute.resource_tracker.ResourceTracker.'
15461546
'_sync_compute_service_disabled_trait')
@@ -1628,7 +1628,7 @@ def test_sync_compute_service_disabled_trait_remove(
16281628
# First test with the trait actually in the set.
16291629
traits = {os_traits.COMPUTE_STATUS_DISABLED}
16301630
self.rt._sync_compute_service_disabled_trait(ctxt, traits)
1631-
self.assertEqual(0, len(traits))
1631+
self.assertEqual(set(), traits)
16321632
mock_get_by_host.assert_called_once_with(ctxt, self.rt.host)
16331633
# Now run it again with the empty set to make sure the method handles
16341634
# the trait not already being in the set (idempotency).

nova/virt/libvirt/driver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3907,6 +3907,8 @@ def _update_compute_provider_status(self, context, service):
39073907
self.virtapi.update_compute_provider_status(
39083908
context, rp_uuid, enabled=not service.disabled)
39093909
except Exception:
3910+
# This is best effort so just log the exception but don't fail.
3911+
# The update_available_resource periodic task will sync the trait.
39103912
LOG.warning(
39113913
'An error occurred while updating compute node '
39123914
'resource provider status to "%s" for provider: %s',

0 commit comments

Comments
 (0)