Skip to content

Commit 69fafb9

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Extend the reproducer for 1953359 and 1952915" into stable/victoria
2 parents 920b3b3 + 8d44874 commit 69fafb9

File tree

1 file changed

+45
-17
lines changed

1 file changed

+45
-17
lines changed

nova/tests/functional/libvirt/test_numa_servers.py

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from oslo_log import log as logging
2222

2323
import nova
24+
from nova.compute import manager
2425
from nova.conf import neutron as neutron_conf
2526
from nova import context as nova_context
2627
from nova import objects
@@ -862,6 +863,7 @@ def test_resize_dedicated_policy_race_on_dest_bug_1953359(self):
862863
# migrate the first instance from compute1 to compute2 but stop
863864
# migrating at the start of finish_resize. Then start a racing periodic
864865
# update_available_resources.
866+
orig_finish_resize = manager.ComputeManager.finish_resize
865867

866868
def fake_finish_resize(*args, **kwargs):
867869
# start a racing update_available_resource periodic
@@ -870,34 +872,60 @@ def fake_finish_resize(*args, **kwargs):
870872
# as the resource_tracker will use the source node numa_topology
871873
# and that does not fit to the dest node as pcpu 0 in the dest
872874
# is already occupied.
875+
log = self.stdlog.logger.output
876+
# The resize_claim correctly calculates that the instance should be
877+
# pinned to pcpu id 1 instead of 0
878+
self.assertIn(
879+
'Computed NUMA topology CPU pinning: usable pCPUs: [[1]], '
880+
'vCPUs mapping: [(0, 1)]',
881+
log,
882+
)
883+
# But the periodic fails as it tries to apply the source topology
884+
# on the dest. This is bug 1953359.
885+
log = self.stdlog.logger.output
886+
self.assertIn('Error updating resources for node compute2', log)
887+
self.assertIn(
888+
'nova.exception.CPUPinningInvalid: CPU set to pin [0] must be '
889+
'a subset of free CPU set [1]',
890+
log,
891+
)
892+
893+
# now let the resize finishes
894+
return orig_finish_resize(*args, **kwargs)
873895

874896
# TODO(stephenfin): The mock of 'migrate_disk_and_power_off' should
875897
# probably be less...dumb
876898
with mock.patch('nova.virt.libvirt.driver.LibvirtDriver'
877899
'.migrate_disk_and_power_off', return_value='{}'):
878900
with mock.patch(
879-
'nova.compute.manager.ComputeManager.finish_resize'
880-
) as mock_finish_resize:
881-
mock_finish_resize.side_effect = fake_finish_resize
901+
'nova.compute.manager.ComputeManager.finish_resize',
902+
new=fake_finish_resize,
903+
):
882904
post = {'migrate': None}
905+
# this is expected to succeed but logs are emitted
906+
# from the racing periodic task. See fake_finish_resize
907+
# for the asserts
883908
self.admin_api.post_server_action(server['id'], post)
884909

885-
log = self.stdlog.logger.output
886-
# The resize_claim correctly calculates that the inst1 should be pinned
887-
# to pcpu id 1 instead of 0
888-
self.assertIn(
889-
'Computed NUMA topology CPU pinning: usable pCPUs: [[1]], '
890-
'vCPUs mapping: [(0, 1)]',
891-
log,
910+
server = self._wait_for_state_change(server, 'VERIFY_RESIZE')
911+
912+
# as the periodic job raced and failed during the resize if we revert
913+
# the instance now then it tries to unpin its cpus from the dest host
914+
# but those was never pinned as the periodic failed. So the unpinning
915+
# will fail too.
916+
post = {'revertResize': {}}
917+
ex = self.assertRaises(
918+
client.OpenStackApiException,
919+
self.admin_api.post_server_action, server['id'], post
892920
)
893-
# But the periodic fails as it tries to apply the source topology on
894-
# the dest. This is bug 1953359.
895-
log = self.stdlog.logger.output
896-
self.assertIn('Error updating resources for node compute2', log)
921+
# This is still bug 1953359.
922+
self.assertEqual(500, ex.response.status_code)
923+
server = self.api.get_server(server['id'])
924+
self.assertEqual('ERROR', server['status'])
897925
self.assertIn(
898-
'nova.exception.CPUPinningInvalid: CPU set to pin [0] must be '
899-
'a subset of free CPU set [1]',
900-
log,
926+
'nova.exception.CPUUnpinningInvalid: CPU set to unpin [1] must be '
927+
'a subset of pinned CPU set [0]',
928+
self.stdlog.logger.output,
901929
)
902930

903931

0 commit comments

Comments
 (0)