34
34
from oslo_log import log as logging
35
35
import oslo_messaging as messaging
36
36
from oslo_serialization import jsonutils
37
- from oslo_utils import excutils
38
37
from oslo_utils import importutils
39
38
from oslo_utils import timeutils
40
39
from oslo_utils import uuidutils
57
56
from nova import objects
58
57
from nova .objects import base as objects_base
59
58
from nova import rpc
60
- from nova import utils
61
59
62
60
CONF = nova .conf .CONF
63
61
@@ -661,19 +659,10 @@ def run_compute_api_method(self, message, method_info):
661
659
expected_attrs = ['metadata' , 'system_metadata' , 'security_groups' ,
662
660
'info_cache' ]
663
661
664
- try :
665
- instance = objects .Instance .get_by_uuid (message .ctxt ,
666
- instance_uuid , expected_attrs = expected_attrs )
667
- args [0 ] = instance
668
- except exception .InstanceNotFound :
669
- with excutils .save_and_reraise_exception ():
670
- # Must be a race condition. Let's try to resolve it by
671
- # telling the top level cells that this instance doesn't
672
- # exist.
673
- instance = objects .Instance (context = message .ctxt ,
674
- uuid = instance_uuid )
675
- self .msg_runner .instance_destroy_at_top (message .ctxt ,
676
- instance )
662
+ instance = objects .Instance .get_by_uuid (message .ctxt ,
663
+ instance_uuid , expected_attrs = expected_attrs )
664
+ args [0 ] = instance
665
+
677
666
return fn (message .ctxt , * args , ** method_info ['method_kwargs' ])
678
667
679
668
def update_capabilities (self , message , cell_name , capabilities ):
@@ -771,18 +760,8 @@ def validate_console_port(self, message, instance_uuid, console_port,
771
760
"""Validate console port with child cell compute node."""
772
761
# 1st arg is instance_uuid that we need to turn into the
773
762
# instance object.
774
- try :
775
- instance = objects .Instance .get_by_uuid (message .ctxt ,
776
- instance_uuid )
777
- except exception .InstanceNotFound :
778
- with excutils .save_and_reraise_exception ():
779
- # Must be a race condition. Let's try to resolve it by
780
- # telling the top level cells that this instance doesn't
781
- # exist.
782
- instance = objects .Instance (context = message .ctxt ,
783
- uuid = instance_uuid )
784
- self .msg_runner .instance_destroy_at_top (message .ctxt ,
785
- instance )
763
+ instance = objects .Instance .get_by_uuid (message .ctxt ,
764
+ instance_uuid )
786
765
return self .compute_rpcapi .validate_console_port (message .ctxt ,
787
766
instance , console_port , console_type )
788
767
@@ -812,15 +791,6 @@ def _call_compute_api_with_obj(self, ctxt, instance, method, *args,
812
791
# NOTE(comstud): We need to refresh the instance from this
813
792
# cell's view in the DB.
814
793
instance .refresh ()
815
- except exception .InstanceNotFound :
816
- with excutils .save_and_reraise_exception ():
817
- # Must be a race condition. Let's try to resolve it by
818
- # telling the top level cells that this instance doesn't
819
- # exist.
820
- instance = objects .Instance (context = ctxt ,
821
- uuid = instance .uuid )
822
- self .msg_runner .instance_destroy_at_top (ctxt ,
823
- instance )
824
794
except exception .InstanceInfoCacheNotFound :
825
795
if method not in ('delete' , 'force_delete' ):
826
796
raise
@@ -1006,70 +976,6 @@ def _get_expected_task_state(self, instance):
1006
976
if instance .obj_attr_is_set ('task_state' ):
1007
977
return expected_task_state_map .get (instance .task_state )
1008
978
1009
- def instance_update_at_top (self , message , instance , ** kwargs ):
1010
- """Update an instance in the DB if we're a top level cell."""
1011
- if not self ._at_the_top ():
1012
- return
1013
-
1014
- # Remove things that we can't update in the top level cells.
1015
- # 'metadata' is only updated in the API cell, so don't overwrite
1016
- # it based on what child cells say. Make sure to update
1017
- # 'cell_name' based on the routing path.
1018
- items_to_remove = ['id' , 'security_groups' , 'volumes' , 'cell_name' ,
1019
- 'name' , 'metadata' ]
1020
- instance .obj_reset_changes (items_to_remove )
1021
- instance .cell_name = _reverse_path (message .routing_path )
1022
-
1023
- # instance.display_name could be unicode
1024
- instance_repr = utils .get_obj_repr_unicode (instance )
1025
- LOG .debug ("Got update for instance: %(instance)s" ,
1026
- {'instance' : instance_repr }, instance_uuid = instance .uuid )
1027
-
1028
- expected_vm_state = self ._get_expected_vm_state (instance )
1029
- expected_task_state = self ._get_expected_task_state (instance )
1030
-
1031
- # It's possible due to some weird condition that the instance
1032
- # was already set as deleted... so we'll attempt to update
1033
- # it with permissions that allows us to read deleted.
1034
- with utils .temporary_mutation (message .ctxt , read_deleted = "yes" ):
1035
- try :
1036
- with instance .skip_cells_sync ():
1037
- instance .save (expected_vm_state = expected_vm_state ,
1038
- expected_task_state = expected_task_state )
1039
- except exception .InstanceNotFound :
1040
- # FIXME(comstud): Strange. Need to handle quotas here,
1041
- # if we actually want this code to remain..
1042
- instance .create ()
1043
- except exception .NotFound :
1044
- # Can happen if we try to update a deleted instance's
1045
- # network information, for example.
1046
- pass
1047
-
1048
- def instance_destroy_at_top (self , message , instance , ** kwargs ):
1049
- """Destroy an instance from the DB if we're a top level cell."""
1050
- if not self ._at_the_top ():
1051
- return
1052
- LOG .debug ("Got update to delete instance" ,
1053
- instance_uuid = instance .uuid )
1054
- try :
1055
- instance .destroy ()
1056
- except exception .InstanceNotFound :
1057
- pass
1058
- except exception .ObjectActionError :
1059
- # NOTE(alaski): instance_destroy_at_top will sometimes be called
1060
- # when an instance does not exist in a cell but does in the parent.
1061
- # In that case instance.id is not set which causes instance.destroy
1062
- # to fail thinking that the object has already been destroyed.
1063
- # That's the right assumption for it to make because without cells
1064
- # that would be true. But for cells we'll try to pull the actual
1065
- # instance and try to delete it again.
1066
- try :
1067
- instance = objects .Instance .get_by_uuid (message .ctxt ,
1068
- instance .uuid )
1069
- instance .destroy ()
1070
- except exception .InstanceNotFound :
1071
- pass
1072
-
1073
979
def instance_delete_everywhere (self , message , instance , delete_type ,
1074
980
** kwargs ):
1075
981
"""Call compute API delete() or soft_delete() in every cell.
@@ -1091,10 +997,7 @@ def bw_usage_update_at_top(self, message, bw_update_info, **kwargs):
1091
997
self .db .bw_usage_update (message .ctxt , ** bw_update_info )
1092
998
1093
999
def _sync_instance (self , ctxt , instance ):
1094
- if instance .deleted :
1095
- self .msg_runner .instance_destroy_at_top (ctxt , instance )
1096
- else :
1097
- self .msg_runner .instance_update_at_top (ctxt , instance )
1000
+ pass
1098
1001
1099
1002
def sync_instances (self , message , project_id , updated_since , deleted ,
1100
1003
** kwargs ):
@@ -1356,20 +1259,6 @@ def run_compute_api_method(self, ctxt, cell_name, method_info, call):
1356
1259
cell_name , need_response = call )
1357
1260
return message .process ()
1358
1261
1359
- def instance_update_at_top (self , ctxt , instance ):
1360
- """Update an instance at the top level cell."""
1361
- message = _BroadcastMessage (self , ctxt , 'instance_update_at_top' ,
1362
- dict (instance = instance ), 'up' ,
1363
- run_locally = False )
1364
- message .process ()
1365
-
1366
- def instance_destroy_at_top (self , ctxt , instance ):
1367
- """Destroy an instance at the top level cell."""
1368
- message = _BroadcastMessage (self , ctxt , 'instance_destroy_at_top' ,
1369
- dict (instance = instance ), 'up' ,
1370
- run_locally = False )
1371
- message .process ()
1372
-
1373
1262
def instance_delete_everywhere (self , ctxt , instance , delete_type ):
1374
1263
"""This is used by API cell when it didn't know what cell
1375
1264
an instance was in, but the instance was requested to be
0 commit comments