Skip to content

Commit 94f17be

Browse files
author
Balazs Gibizer
committed
Extend the reproducer for 1953359 and 1952915
This patch extends the original reproduction I4be429c56aaa15ee12f448978c38214e741eae63 to cover bug 1952915 as well as they have a common root cause. Change-Id: I57982131768d87e067d1413012b96f1baa68052b Related-Bug: #1953359 Related-Bug: #1952915 (cherry picked from commit 9f296d7) (cherry picked from commit 0411962)
1 parent d8859e4 commit 94f17be

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
@@ -20,6 +20,7 @@
2020
from oslo_log import log as logging
2121

2222
import nova
23+
from nova.compute import manager
2324
from nova.conf import neutron as neutron_conf
2425
from nova import context as nova_context
2526
from nova import objects
@@ -973,6 +974,7 @@ def test_resize_dedicated_policy_race_on_dest_bug_1953359(self):
973974
# migrate the first instance from compute1 to compute2 but stop
974975
# migrating at the start of finish_resize. Then start a racing periodic
975976
# update_available_resources.
977+
orig_finish_resize = manager.ComputeManager.finish_resize
976978

977979
def fake_finish_resize(*args, **kwargs):
978980
# start a racing update_available_resource periodic
@@ -981,34 +983,60 @@ def fake_finish_resize(*args, **kwargs):
981983
# as the resource_tracker will use the source node numa_topology
982984
# and that does not fit to the dest node as pcpu 0 in the dest
983985
# is already occupied.
986+
log = self.stdlog.logger.output
987+
# The resize_claim correctly calculates that the instance should be
988+
# pinned to pcpu id 1 instead of 0
989+
self.assertIn(
990+
'Computed NUMA topology CPU pinning: usable pCPUs: [[1]], '
991+
'vCPUs mapping: [(0, 1)]',
992+
log,
993+
)
994+
# But the periodic fails as it tries to apply the source topology
995+
# on the dest. This is bug 1953359.
996+
log = self.stdlog.logger.output
997+
self.assertIn('Error updating resources for node compute2', log)
998+
self.assertIn(
999+
'nova.exception.CPUPinningInvalid: CPU set to pin [0] must be '
1000+
'a subset of free CPU set [1]',
1001+
log,
1002+
)
1003+
1004+
# now let the resize finishes
1005+
return orig_finish_resize(*args, **kwargs)
9841006

9851007
# TODO(stephenfin): The mock of 'migrate_disk_and_power_off' should
9861008
# probably be less...dumb
9871009
with mock.patch('nova.virt.libvirt.driver.LibvirtDriver'
9881010
'.migrate_disk_and_power_off', return_value='{}'):
9891011
with mock.patch(
990-
'nova.compute.manager.ComputeManager.finish_resize'
991-
) as mock_finish_resize:
992-
mock_finish_resize.side_effect = fake_finish_resize
1012+
'nova.compute.manager.ComputeManager.finish_resize',
1013+
new=fake_finish_resize,
1014+
):
9931015
post = {'migrate': None}
1016+
# this is expected to succeed but logs are emitted
1017+
# from the racing periodic task. See fake_finish_resize
1018+
# for the asserts
9941019
self.admin_api.post_server_action(server['id'], post)
9951020

996-
log = self.stdlog.logger.output
997-
# The resize_claim correctly calculates that the inst1 should be pinned
998-
# to pcpu id 1 instead of 0
999-
self.assertIn(
1000-
'Computed NUMA topology CPU pinning: usable pCPUs: [[1]], '
1001-
'vCPUs mapping: [(0, 1)]',
1002-
log,
1021+
server = self._wait_for_state_change(server, 'VERIFY_RESIZE')
1022+
1023+
# as the periodic job raced and failed during the resize if we revert
1024+
# the instance now then it tries to unpin its cpus from the dest host
1025+
# but those was never pinned as the periodic failed. So the unpinning
1026+
# will fail too.
1027+
post = {'revertResize': {}}
1028+
ex = self.assertRaises(
1029+
client.OpenStackApiException,
1030+
self.admin_api.post_server_action, server['id'], post
10031031
)
1004-
# But the periodic fails as it tries to apply the source topology on
1005-
# the dest. This is bug 1953359.
1006-
log = self.stdlog.logger.output
1007-
self.assertIn('Error updating resources for node compute2', log)
1032+
# This is still bug 1953359.
1033+
self.assertEqual(500, ex.response.status_code)
1034+
server = self.api.get_server(server['id'])
1035+
self.assertEqual('ERROR', server['status'])
10081036
self.assertIn(
1009-
'nova.exception.CPUPinningInvalid: CPU set to pin [0] must be '
1010-
'a subset of free CPU set [1]',
1011-
log,
1037+
'nova.exception.CPUUnpinningInvalid: CPU set to unpin [1] must be '
1038+
'a subset of pinned CPU set [0]',
1039+
self.stdlog.logger.output,
10121040
)
10131041

10141042

0 commit comments

Comments
 (0)