(
&self,
sandbox_id: &str,
gpu_device: &str,
)
| 1605 | } |
| 1606 | |
| 1607 | async fn assign_gpu_to_record( |
| 1608 | &self, |
| 1609 | sandbox_id: &str, |
| 1610 | gpu_device: &str, |
| 1611 | ) -> Result<String, Status> { |
| 1612 | let mut registry = self.registry.lock().await; |
| 1613 | match registry.get_mut(sandbox_id) { |
| 1614 | Some(record) if !record.deleting => {} |
| 1615 | _ => return Err(Status::cancelled("sandbox provisioning cancelled")), |
| 1616 | } |
| 1617 | |
| 1618 | let inventory = self |
| 1619 | .gpu_inventory |
| 1620 | .as_ref() |
| 1621 | .ok_or_else(|| Status::internal("GPU inventory not initialized"))?; |
| 1622 | let assignment = inventory |
| 1623 | .lock() |
| 1624 | .map_err(|e| Status::internal(format!("GPU inventory lock poisoned: {e}")))? |
| 1625 | .assign(sandbox_id, gpu_device) |
| 1626 | .map_err(Status::failed_precondition)?; |
| 1627 | |
| 1628 | let record = registry |
| 1629 | .get_mut(sandbox_id) |
| 1630 | .expect("sandbox record exists while registry lock is held"); |
| 1631 | record.gpu_bdf = Some(assignment.bdf.clone()); |
| 1632 | tracing::info!( |
| 1633 | sandbox_id = %sandbox_id, |
| 1634 | bdf = %assignment.bdf, |
| 1635 | gpu_name = %assignment.name, |
| 1636 | iommu_group = assignment.iommu_group, |
| 1637 | "assigned GPU to sandbox" |
| 1638 | ); |
| 1639 | Ok(assignment.bdf) |
| 1640 | } |
| 1641 | |
| 1642 | async fn fail_provisioning( |
| 1643 | &self, |
no test coverage detected