File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
src/dstack/_internal/core/backends/cloudrift Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -155,8 +155,20 @@ def terminate_instance(self, instance_id: str) -> bool:
155155 logger .debug ("Terminating instance with request data: %s" , request_data )
156156 response_data = self ._make_request ("instances/terminate" , request_data )
157157 if isinstance (response_data , dict ):
158+ logger .debug ("Terminating instance with response: %s" , response_data )
158159 info = response_data .get ("terminated" , [])
159- return len (info ) > 0
160+ is_terminated = len (info ) > 0
161+ if not is_terminated :
162+ # check if the instance is already terminated
163+ instance_info = self .get_instance_by_id (instance_id )
164+ is_terminated = instance_info is None or instance_info .get ("status" ) == "Inactive"
165+ logger .debug (
166+ "Instance %s is already terminated: %s response: %s" ,
167+ instance_id ,
168+ is_terminated ,
169+ instance_info ,
170+ )
171+ return is_terminated
160172
161173 return False
162174
You can’t perform that action at this time.
0 commit comments