20
20
from oslo_log import log as logging
21
21
22
22
import nova
23
+ from nova .compute import manager
23
24
from nova .conf import neutron as neutron_conf
24
25
from nova import context as nova_context
25
26
from nova import objects
@@ -972,6 +973,7 @@ def test_resize_dedicated_policy_race_on_dest_bug_1953359(self):
972
973
# migrate the first instance from compute1 to compute2 but stop
973
974
# migrating at the start of finish_resize. Then start a racing periodic
974
975
# update_available_resources.
976
+ orig_finish_resize = manager .ComputeManager .finish_resize
975
977
976
978
def fake_finish_resize (* args , ** kwargs ):
977
979
# start a racing update_available_resource periodic
@@ -980,34 +982,60 @@ def fake_finish_resize(*args, **kwargs):
980
982
# as the resource_tracker will use the source node numa_topology
981
983
# and that does not fit to the dest node as pcpu 0 in the dest
982
984
# is already occupied.
985
+ log = self .stdlog .logger .output
986
+ # The resize_claim correctly calculates that the instance should be
987
+ # pinned to pcpu id 1 instead of 0
988
+ self .assertIn (
989
+ 'Computed NUMA topology CPU pinning: usable pCPUs: [[1]], '
990
+ 'vCPUs mapping: [(0, 1)]' ,
991
+ log ,
992
+ )
993
+ # But the periodic fails as it tries to apply the source topology
994
+ # on the dest. This is bug 1953359.
995
+ log = self .stdlog .logger .output
996
+ self .assertIn ('Error updating resources for node compute2' , log )
997
+ self .assertIn (
998
+ 'nova.exception.CPUPinningInvalid: CPU set to pin [0] must be '
999
+ 'a subset of free CPU set [1]' ,
1000
+ log ,
1001
+ )
1002
+
1003
+ # now let the resize finishes
1004
+ return orig_finish_resize (* args , ** kwargs )
983
1005
984
1006
# TODO(stephenfin): The mock of 'migrate_disk_and_power_off' should
985
1007
# probably be less...dumb
986
1008
with mock .patch ('nova.virt.libvirt.driver.LibvirtDriver'
987
1009
'.migrate_disk_and_power_off' , return_value = '{}' ):
988
1010
with mock .patch (
989
- 'nova.compute.manager.ComputeManager.finish_resize'
990
- ) as mock_finish_resize :
991
- mock_finish_resize . side_effect = fake_finish_resize
1011
+ 'nova.compute.manager.ComputeManager.finish_resize' ,
1012
+ new = fake_finish_resize ,
1013
+ ):
992
1014
post = {'migrate' : None }
1015
+ # this is expected to succeed but logs are emitted
1016
+ # from the racing periodic task. See fake_finish_resize
1017
+ # for the asserts
993
1018
self .admin_api .post_server_action (server ['id' ], post )
994
1019
995
- log = self .stdlog .logger .output
996
- # The resize_claim correctly calculates that the inst1 should be pinned
997
- # to pcpu id 1 instead of 0
998
- self .assertIn (
999
- 'Computed NUMA topology CPU pinning: usable pCPUs: [[1]], '
1000
- 'vCPUs mapping: [(0, 1)]' ,
1001
- log ,
1020
+ server = self ._wait_for_state_change (server , 'VERIFY_RESIZE' )
1021
+
1022
+ # as the periodic job raced and failed during the resize if we revert
1023
+ # the instance now then it tries to unpin its cpus from the dest host
1024
+ # but those was never pinned as the periodic failed. So the unpinning
1025
+ # will fail too.
1026
+ post = {'revertResize' : {}}
1027
+ ex = self .assertRaises (
1028
+ client .OpenStackApiException ,
1029
+ self .admin_api .post_server_action , server ['id' ], post
1002
1030
)
1003
- # But the periodic fails as it tries to apply the source topology on
1004
- # the dest. This is bug 1953359.
1005
- log = self .stdlog . logger . output
1006
- self .assertIn ( 'Error updating resources for node compute2 ' , log )
1031
+ # This is still bug 1953359.
1032
+ self . assertEqual ( 500 , ex . response . status_code )
1033
+ server = self .api . get_server ( server [ 'id' ])
1034
+ self .assertEqual ( 'ERROR ' , server [ 'status' ] )
1007
1035
self .assertIn (
1008
- 'nova.exception.CPUPinningInvalid : CPU set to pin [0 ] must be '
1009
- 'a subset of free CPU set [1 ]' ,
1010
- log ,
1036
+ 'nova.exception.CPUUnpinningInvalid : CPU set to unpin [1 ] must be '
1037
+ 'a subset of pinned CPU set [0 ]' ,
1038
+ self . stdlog . logger . output ,
1011
1039
)
1012
1040
1013
1041
0 commit comments