(&self, sandbox: &Sandbox)
| 526 | |
| 527 | #[allow(clippy::similar_names)] |
| 528 | pub async fn create_sandbox(&self, sandbox: &Sandbox) -> Result<(), KubernetesDriverError> { |
| 529 | let _ = KubernetesSandboxDriverConfig::from_sandbox(sandbox) |
| 530 | .map_err(KubernetesDriverError::InvalidArgument)?; |
| 531 | let gpu_requirements = sandbox |
| 532 | .spec |
| 533 | .as_ref() |
| 534 | .and_then(|spec| driver_gpu_requirements(spec.resource_requirements.as_ref())); |
| 535 | validate_gpu_request(gpu_requirements).map_err(|status| { |
| 536 | KubernetesDriverError::InvalidArgument(status.message().to_string()) |
| 537 | })?; |
| 538 | let name = sandbox.name.as_str(); |
| 539 | info!( |
| 540 | sandbox_id = %sandbox.id, |
| 541 | sandbox_name = %name, |
| 542 | namespace = %self.config.namespace, |
| 543 | "Creating sandbox in Kubernetes" |
| 544 | ); |
| 545 | |
| 546 | let agent_sandbox_api = self |
| 547 | .supported_agent_sandbox_api(self.client.clone()) |
| 548 | .await |
| 549 | .map_err(KubernetesDriverError::Message)?; |
| 550 | |
| 551 | // Resolve sandbox UID/GID from config or OpenShift SCC namespace annotations. |
| 552 | let (resolved_uid, resolved_gid, ns_annotations) = self.resolve_sandbox_identity().await; |
| 553 | |
| 554 | let params = SandboxPodParams { |
| 555 | default_image: &self.config.default_image, |
| 556 | image_pull_policy: &self.config.image_pull_policy, |
| 557 | image_pull_secrets: &self.config.image_pull_secrets, |
| 558 | supervisor_image: &self.config.supervisor_image, |
| 559 | supervisor_image_pull_policy: &self.config.supervisor_image_pull_policy, |
| 560 | supervisor_sideload_method: self.config.supervisor_sideload_method, |
| 561 | service_account_name: &self.config.service_account_name, |
| 562 | sandbox_id: &sandbox.id, |
| 563 | sandbox_name: &sandbox.name, |
| 564 | grpc_endpoint: &self.config.grpc_endpoint, |
| 565 | ssh_socket_path: self.ssh_socket_path(), |
| 566 | client_tls_secret_name: &self.config.client_tls_secret_name, |
| 567 | host_gateway_ip: &self.config.host_gateway_ip, |
| 568 | enable_user_namespaces: self.config.enable_user_namespaces, |
| 569 | app_armor_profile: self.config.app_armor_profile.as_ref(), |
| 570 | workspace_default_storage_size: &self.config.workspace_default_storage_size, |
| 571 | default_runtime_class_name: &self.config.default_runtime_class_name, |
| 572 | sa_token_ttl_secs: self.config.effective_sa_token_ttl_secs(), |
| 573 | provider_spiffe_enabled: self.config.provider_spiffe_enabled(), |
| 574 | provider_spiffe_workload_api_socket_path: &self |
| 575 | .config |
| 576 | .provider_spiffe_workload_api_socket_path, |
| 577 | sandbox_uid: resolved_uid, |
| 578 | sandbox_gid: resolved_gid, |
| 579 | }; |
| 580 | |
| 581 | let mut obj = DynamicObject::new(name, &agent_sandbox_api.resource); |
| 582 | // Copy only the SCC-related annotations onto the Sandbox CR for |
| 583 | // traceability. Copying the full namespace annotation map exposes |
| 584 | // unrelated cluster metadata and can fail with oversized annotations. |
| 585 | let scc_annotations: BTreeMap<String, String> = [ |
nothing calls this directly
no test coverage detected