@@ -239,7 +239,7 @@ impl KubernetesComputeDriver {
239239 . admit_requested_resources ( & sandbox)
240240 . await
241241 . map_err ( admission_error) ?;
242- let ( uid, gid, _ ) = self . resolve_sandbox_identity_in_namespace ( & namespace) . await ;
242+ let ( uid, gid) = self . warm_namespace_identity ( & namespace) . await ? ;
243243 let physical_id = request. session_id . to_string ( ) ;
244244 let names = SandboxRuntimeNames :: for_generation ( & physical_id, & physical_id) ;
245245 let ( data, child_env) =
@@ -340,15 +340,25 @@ impl KubernetesComputeDriver {
340340 pub async fn warm_runtime_inventory (
341341 & self ,
342342 workspace : & str ,
343+ ) -> Result < Vec < WarmRuntimeResource > , KubernetesDriverError > {
344+ self . list_warm_runtime_inventory ( workspace, None ) . await
345+ }
346+
347+ async fn list_warm_runtime_inventory (
348+ & self ,
349+ workspace : & str ,
350+ pool_id : Option < & str > ,
343351 ) -> Result < Vec < WarmRuntimeResource > , KubernetesDriverError > {
344352 self . check_warm_runtime_support ( ) ?;
345353 let namespace = self . warm_runtime_namespace ( workspace) . await ?;
346354 let api = self
347355 . supported_agent_sandbox_api ( self . client . clone ( ) , & namespace)
348356 . await
349357 . map_err ( KubernetesDriverError :: Message ) ?;
358+ let pool_selector =
359+ pool_id. map_or_else ( || POOL_LABEL . to_string ( ) , |id| format ! ( "{POOL_LABEL}={id}" ) ) ;
350360 let selector = format ! (
351- "{LABEL_MANAGED_BY}={LABEL_MANAGED_BY_VALUE},{LABEL_GATEWAY_ID}={},{}={workspace},{POOL_LABEL }" ,
361+ "{LABEL_MANAGED_BY}={LABEL_MANAGED_BY_VALUE},{LABEL_GATEWAY_ID}={},{}={workspace},{pool_selector }" ,
352362 self . config. gateway_id, LABEL_SANDBOX_WORKSPACE
353363 ) ;
354364 let objects = api
@@ -405,7 +415,7 @@ impl KubernetesComputeDriver {
405415 if annotation_or_label ( & object, LABEL_SANDBOX_ID ) . is_some ( )
406416 && !self
407417 . warm_supervision ( ) ?
408- . pending_warm_claims ( & record. workspace )
418+ . pending_warm_claims ( & record. workspace , & record . pool_id )
409419 . await
410420 . map_err ( KubernetesDriverError :: Message ) ?
411421 . retired
@@ -497,6 +507,26 @@ impl KubernetesComputeDriver {
497507 Ok ( ( ) )
498508 }
499509
510+ async fn warm_namespace_identity (
511+ & self ,
512+ namespace : & str ,
513+ ) -> Result < ( u32 , u32 ) , KubernetesDriverError > {
514+ if let Some ( uid) = self . config . sandbox_uid {
515+ return Ok ( ( uid, self . config . resolve_sandbox_gid ( uid, None ) ) ) ;
516+ }
517+ let ns = Api :: < Namespace > :: all ( self . client . clone ( ) )
518+ . get ( namespace)
519+ . await
520+ . map_err ( KubernetesDriverError :: from_kube) ?;
521+ Ok ( self . warm_pod_identity ( & ns) )
522+ }
523+
524+ fn warm_pod_identity ( & self , ns : & Namespace ) -> ( u32 , u32 ) {
525+ let annotations = ns. metadata . annotations . as_ref ( ) ;
526+ let uid = self . config . resolve_sandbox_uid ( annotations) ;
527+ ( uid, self . config . resolve_sandbox_gid ( uid, annotations) )
528+ }
529+
500530 async fn warm_runtime_namespace (
501531 & self ,
502532 workspace : & str ,
0 commit comments