MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / remove_instance

Method remove_instance

gateway/src/main_service.rs:1234–1254  ·  view source on GitHub ↗
(&mut self, id: &str)

Source from the content-addressed store, hash-verified

1232 }
1233
1234 fn remove_instance(&mut self, id: &str) -> Result<()> {
1235 let info = self
1236 .state
1237 .instances
1238 .remove(id)
1239 .context("instance not found")?;
1240
1241 // Sync deletion to KvStore
1242 if let Err(err) = self.kv_store.sync_delete_instance(id) {
1243 error!("Failed to sync instance deletion to KvStore: {err:?}");
1244 }
1245
1246 self.state.allocated_addresses.remove(&info.ip);
1247 if let Some(app_instances) = self.state.apps.get_mut(&info.app_id) {
1248 app_instances.remove(id);
1249 if app_instances.is_empty() {
1250 self.state.apps.remove(&info.app_id);
1251 }
1252 }
1253 Ok(())
1254 }
1255
1256 fn recycle(&mut self) -> Result<()> {
1257 // Refresh state: sync local handshakes to KvStore, update local last_seen from global

Callers 1

recycleMethod · 0.80

Calls 4

sync_delete_instanceMethod · 0.80
get_mutMethod · 0.80
removeMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected