File tree Expand file tree Collapse file tree
src/dstack/_internal/server
background/pipeline_tasks/instances Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212from dstack ._internal .server .services import backends as backends_services
1313from dstack ._internal .server .services .instances import get_instance_provisioning_data
1414from dstack ._internal .server .services .runner .pool import (
15- InstanceConnectionKey ,
1615 instance_connection_pool ,
1716)
1817from dstack ._internal .utils .common import get_current_datetime , run_async
@@ -82,7 +81,7 @@ async def terminate_instance(instance_model: InstanceModel) -> ProcessResult:
8281 )
8382
8483 if job_provisioning_data is not None :
85- instance_connection_pool .drop ( InstanceConnectionKey . from_jpd ( job_provisioning_data ) )
84+ instance_connection_pool .drop_by_jpd ( job_provisioning_data )
8685
8786 result .instance_update_map ["deleted" ] = True
8887 result .instance_update_map ["deleted_at" ] = NOW_PLACEHOLDER
Original file line number Diff line number Diff line change @@ -130,6 +130,12 @@ def drop(self, key: InstanceConnectionKey) -> None:
130130 except Exception :
131131 logger .exception ("Failed to close instance connection %s" , key )
132132
133+ def drop_by_jpd (self , jpd : JobProvisioningData , jrd : Optional [JobRuntimeData ] = None ):
134+ if jpd .hostname is None or jpd .ssh_port is None :
135+ return
136+ key = InstanceConnectionKey .from_jpd (jpd , jrd )
137+ self .drop (key )
138+
133139 def startup_cleanup (self ) -> None :
134140 """
135141 Removes connection dirs left by a previous server process (e.g. after SIGKILL).
You can’t perform that action at this time.
0 commit comments