MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / prune_missing_sandbox

Method prune_missing_sandbox

crates/openshell-server/src/compute/mod.rs:1447–1489  ·  view source on GitHub ↗
(
        &self,
        record: ObjectRecord,
        sweep_started_at_ms: i64,
        grace_ms: i64,
    )

Source from the content-addressed store, hash-verified

1445 }
1446
1447 async fn prune_missing_sandbox(
1448 &self,
1449 record: ObjectRecord,
1450 sweep_started_at_ms: i64,
1451 grace_ms: i64,
1452 ) -> Result<(), String> {
1453 let _guard = self.sync_lock.lock().await;
1454 let Some(current_record) = self
1455 .store
1456 .get(Sandbox::object_type(), &record.id)
1457 .await
1458 .map_err(|e| e.to_string())?
1459 else {
1460 return Ok(());
1461 };
1462
1463 if current_record.updated_at_ms > sweep_started_at_ms {
1464 return Ok(());
1465 }
1466
1467 let sandbox = decode_sandbox_record(&current_record)?;
1468 let age_ms = openshell_core::time::now_ms().saturating_sub(current_record.created_at_ms);
1469 if age_ms < grace_ms {
1470 return Ok(());
1471 }
1472
1473 if let Some(current) = self
1474 .get_driver_sandbox(sandbox.object_id(), sandbox.object_name())
1475 .await?
1476 {
1477 return self
1478 .apply_sandbox_update_locked(current, Some(current_record))
1479 .await;
1480 }
1481
1482 info!(
1483 sandbox_id = %sandbox.object_id(),
1484 sandbox_name = %sandbox.object_name(),
1485 age_secs = age_ms / 1000,
1486 "Removing sandbox from store after it disappeared from the compute driver snapshot"
1487 );
1488 self.apply_deleted_locked(sandbox.object_id()).await
1489 }
1490
1491 async fn get_driver_sandbox(
1492 &self,

Callers 1

Calls 8

decode_sandbox_recordFunction · 0.85
now_msFunction · 0.85
get_driver_sandboxMethod · 0.80
object_idMethod · 0.80
object_nameMethod · 0.80
apply_deleted_lockedMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected