Skip to content

Commit 12a6fe5

Browse files
committed
1 parent 3f0605c commit 12a6fe5

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
@@ -5129,10 +5129,12 @@ def _update_compute_provider_status(self, context, service):
51295129
'COMPUTE_STATUS_DISABLED trait.', service.host)
51305130
self.rpcapi.set_host_enabled(context, service.host, enabled)
51315131
except Exception:
5132-
LOG.exception('An error occurred while updating host enabled '
5133-
'status to "%s" for compute host: %s',
5134-
'enabled' if enabled else 'disabled',
5135-
service.host)
5132+
LOG.exception('An error occurred while updating the '
5133+
'COMPUTE_STATUS_DISABLED trait on compute node '
5134+
'resource providers managed by host %s. The trait '
5135+
'will be synchronized automatically by the compute '
5136+
'service when the update_available_resource '
5137+
'periodic task runs.', service.host)
51365138

51375139
def service_update(self, context, service):
51385140
"""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
@@ -1450,8 +1450,8 @@ def test_existing_node_capabilities_as_traits(self, mock_sync_disabled):
14501450
@mock.patch('nova.compute.resource_tracker.ResourceTracker.'
14511451
'_sync_compute_service_disabled_trait')
14521452
@mock.patch('nova.objects.ComputeNode.save')
1453-
def test_existing_node_update_provider_tree_implemented(self, save_mock,
1454-
mock_sync_disable):
1453+
def test_existing_node_update_provider_tree_implemented(
1454+
self, save_mock, mock_sync_disabled):
14551455
"""The update_provider_tree() virt driver method is only implemented
14561456
for some virt drivers. This method returns inventory, trait, and
14571457
aggregate information for resource providers in a tree associated with
@@ -1534,7 +1534,7 @@ def fake_upt(ptree, nodename, allocations=None):
15341534
# 1024MB in GB
15351535
exp_inv[orc.DISK_GB]['reserved'] = 1
15361536
self.assertEqual(exp_inv, ptree.data(new_compute.uuid).inventory)
1537-
mock_sync_disable.assert_called_once()
1537+
mock_sync_disabled.assert_called_once()
15381538

15391539
@mock.patch('nova.compute.resource_tracker.ResourceTracker.'
15401540
'_sync_compute_service_disabled_trait')
@@ -1622,7 +1622,7 @@ def test_sync_compute_service_disabled_trait_remove(
16221622
# First test with the trait actually in the set.
16231623
traits = {os_traits.COMPUTE_STATUS_DISABLED}
16241624
self.rt._sync_compute_service_disabled_trait(ctxt, traits)
1625-
self.assertEqual(0, len(traits))
1625+
self.assertEqual(set(), traits)
16261626
mock_get_by_host.assert_called_once_with(ctxt, self.rt.host)
16271627
# Now run it again with the empty set to make sure the method handles
16281628
# 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
@@ -3915,6 +3915,8 @@ def _update_compute_provider_status(self, context, service):
39153915
self.virtapi.update_compute_provider_status(
39163916
context, rp_uuid, enabled=not service.disabled)
39173917
except Exception:
3918+
# This is best effort so just log the exception but don't fail.
3919+
# The update_available_resource periodic task will sync the trait.
39183920
LOG.warning(
39193921
'An error occurred while updating compute node '
39203922
'resource provider status to "%s" for provider: %s',

0 commit comments

Comments
 (0)