Skip to content

Commit e073be7

Browse files
committed
feat(docker): project CDI spec directories and record the CDI context
For GPU sandboxes, record the selected CDI device IDs and the spec directories the Docker daemon currently reports in the protected boundary configuration, and project those directories read-only under /.openshell/cdi-specs so the sandbox runtime can resolve the same specs. User mounts, image volumes and the workspace cannot overlap the projection path. Before creating the sandbox, probe each directory with a stopped container from the prepared workload image and skip directories that do not exist on the Docker host. Probes are bounded by a timeout, labelled for cleanup with their sandbox, and remove their anonymous volumes. A probe that cannot be removed no longer fails creation. With resource admission enabled, containers with a CDI context must keep a CDI device request matching the recorded selection and one read-only, non-recursive, private bind per recorded directory. Admission reads the bootstrap only for CDI containers, and boundary files are replaced atomically so it never observes a partial write. The Docker e2e gateway enables resource admission in GPU mode. Signed-off-by: Evan Lezar <elezar@nvidia.com>
1 parent f2b739d commit e073be7

4 files changed

Lines changed: 1617 additions & 41 deletions

File tree

‎crates/openshell-driver-docker/src/isolation.rs‎

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use std::collections::{BTreeMap, HashMap};
1111
use std::net::IpAddr;
1212
use std::path::PathBuf;
1313

14+
use openshell_core::cdi::CdiContext;
1415
use openshell_isolation_interface::contract::{
1516
BackendError, OuterFenceGuarantee, OuterFenceGuarantees, ResolvedWorkloadIdentity,
1617
};
@@ -70,6 +71,7 @@ pub struct DockerBoundarySpec {
7071
pub container_id: String,
7172
pub image_identity: String,
7273
pub gpu_requested: bool,
74+
pub cdi_context: Option<CdiContext>,
7375
pub listener_socket: PathBuf,
7476
pub control_socket: PathBuf,
7577
pub sandbox_tls: SandboxTlsServerConfig,
@@ -118,7 +120,7 @@ impl DockerBoundarySpec {
118120
},
119121
resource_claims: resource_claims.clone(),
120122
resource_claim_files: BTreeMap::new(),
121-
cdi_context: None,
123+
cdi_context: self.cdi_context,
122124
workload_identity: self.workload_identity.clone(),
123125
outer_fence: outer_fence.clone(),
124126
child_env: self.child_env,
@@ -188,6 +190,13 @@ mod tests {
188190
container_id: "sha256:container".to_string(),
189191
image_identity: "sha256:image".to_string(),
190192
gpu_requested: true,
193+
cdi_context: Some(CdiContext::new(
194+
vec!["nvidia.com/gpu=0".to_string()],
195+
vec![openshell_core::cdi::CdiSpecDirectory::new(
196+
openshell_core::cdi::cdi_spec_mount_path(0),
197+
"/var/run/cdi",
198+
)],
199+
)),
191200
listener_socket: PathBuf::from("/run/openshell/boundary/control.sock"),
192201
control_socket: PathBuf::from("/host/control.sock"),
193202
sandbox_tls: SandboxTlsServerConfig {
@@ -224,6 +233,15 @@ mod tests {
224233
provisioned.runtime_descriptor.resource_claims[GPU_RESOURCE_CLAIM],
225234
"true"
226235
);
236+
assert_eq!(
237+
provisioned
238+
.boundary_config
239+
.cdi_context
240+
.as_ref()
241+
.unwrap()
242+
.selected_devices,
243+
["nvidia.com/gpu=0"]
244+
);
227245
assert_eq!(
228246
provisioned.boundary_config.outer_fence,
229247
provisioned.runtime_descriptor.outer_fence

0 commit comments

Comments
 (0)