@@ -79,15 +79,53 @@ const HOST_OPENSHELL_INTERNAL: &str = "host.openshell.internal";
7979const HOST_DOCKER_INTERNAL : & str = "host.docker.internal" ;
8080const DOCKER_NETWORK_DRIVER : & str = "bridge" ;
8181
82- /// Queried by the Docker driver to decide when a sandbox's supervisor
83- /// relay is live. Implementations return `true` once a sandbox has an
84- /// active `ConnectSupervisor` session registered.
82+ /// Default image holding the Linux `openshell-sandbox` binary. The gateway
83+ /// pulls this image and extracts the binary to a host-side cache when no
84+ /// explicit `supervisor_bin`, configured `supervisor_image`, sibling binary,
85+ /// or local build is available.
86+ const DEFAULT_DOCKER_SUPERVISOR_IMAGE_REPO : & str = "ghcr.io/nvidia/openshell/supervisor" ;
87+
88+ /// Return the default `ghcr.io/nvidia/openshell/supervisor:<tag>` reference
89+ /// used when no supervisor binary override is provided.
90+ pub fn default_docker_supervisor_image ( ) -> String {
91+ format ! (
92+ "{DEFAULT_DOCKER_SUPERVISOR_IMAGE_REPO}:{}" ,
93+ default_docker_supervisor_image_tag( )
94+ )
95+ }
96+
97+ /// Image tag baked in at compile time to pair the gateway with a matching
98+ /// supervisor image.
8599///
86- /// The driver cannot observe the supervisor's SSH socket directly (it
87- /// lives inside the container), so it leans on this signal to flip the
88- /// Ready condition from `DependenciesNotReady` to `True`.
89- pub trait SupervisorReadiness : Send + Sync + ' static {
90- fn is_supervisor_connected ( & self , sandbox_id : & str ) -> bool ;
100+ /// Build pipelines pass `OPENSHELL_IMAGE_TAG` explicitly. The `IMAGE_TAG`
101+ /// fallback covers image build wrappers that already tag the gateway and
102+ /// supervisor together. Standalone release binaries also patch the Cargo
103+ /// package version, so use it when it has been set to a real release value.
104+ fn default_docker_supervisor_image_tag ( ) -> String {
105+ resolve_default_docker_supervisor_image_tag (
106+ option_env ! ( "OPENSHELL_IMAGE_TAG" ) ,
107+ option_env ! ( "IMAGE_TAG" ) ,
108+ env ! ( "CARGO_PKG_VERSION" ) ,
109+ )
110+ }
111+
112+ fn resolve_default_docker_supervisor_image_tag (
113+ openshell_image_tag : Option < & ' static str > ,
114+ image_tag : Option < & ' static str > ,
115+ cargo_pkg_version : & ' static str ,
116+ ) -> String {
117+ let tag = openshell_image_tag
118+ . filter ( |tag| !tag. is_empty ( ) )
119+ . or_else ( || image_tag. filter ( |tag| !tag. is_empty ( ) ) )
120+ . unwrap_or_else ( || {
121+ if cargo_pkg_version. is_empty ( ) || cargo_pkg_version == "0.0.0" {
122+ "dev"
123+ } else {
124+ cargo_pkg_version
125+ }
126+ } ) ;
127+
128+ tag. replace ( '+' , "-" )
91129}
92130
93131/// Gateway-local configuration for the Docker compute driver.
@@ -212,7 +250,6 @@ pub struct DockerComputeDriver {
212250 config : DockerDriverRuntimeConfig ,
213251 events : broadcast:: Sender < WatchSandboxesEvent > ,
214252 pending : Arc < Mutex < HashMap < String , PendingSandboxRecord > > > ,
215- supervisor_readiness : Arc < dyn SupervisorReadiness > ,
216253 gpu_selector : Arc < CdiGpuDefaultSelector > ,
217254}
218255
@@ -309,11 +346,7 @@ type WatchStream =
309346 Pin < Box < dyn Stream < Item = Result < WatchSandboxesEvent , Status > > + Send + ' static > > ;
310347
311348impl DockerComputeDriver {
312- pub async fn new (
313- config : & Config ,
314- docker_config : & DockerComputeConfig ,
315- supervisor_readiness : Arc < dyn SupervisorReadiness > ,
316- ) -> CoreResult < Self > {
349+ pub async fn new ( config : & Config , docker_config : & DockerComputeConfig ) -> CoreResult < Self > {
317350 let socket_path = docker_config
318351 . socket_path
319352 . clone ( )
@@ -395,7 +428,6 @@ impl DockerComputeDriver {
395428 } ,
396429 events : broadcast:: channel ( WATCH_BUFFER ) . 0 ,
397430 pending : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
398- supervisor_readiness,
399431 gpu_selector : Arc :: new ( CdiGpuDefaultSelector :: new (
400432 cdi_gpu_inventory,
401433 allow_all_default_gpu,
@@ -606,9 +638,9 @@ impl DockerComputeDriver {
606638 let container = self
607639 . find_managed_container_summary ( sandbox_id, sandbox_name)
608640 . await ?;
609- if let Some ( sandbox) = container . and_then ( |summary| {
610- sandbox_from_container_summary ( & summary, self . supervisor_readiness . as_ref ( ) )
611- } ) {
641+ if let Some ( sandbox) =
642+ container . and_then ( | summary| sandbox_from_container_summary ( & summary ) )
643+ {
612644 return Ok ( Some ( sandbox) ) ;
613645 }
614646
@@ -619,9 +651,7 @@ impl DockerComputeDriver {
619651 let containers = self . list_managed_container_summaries ( ) . await ?;
620652 let container_sandboxes = containers
621653 . iter ( )
622- . filter_map ( |summary| {
623- sandbox_from_container_summary ( summary, self . supervisor_readiness . as_ref ( ) )
624- } )
654+ . filter_map ( sandbox_from_container_summary)
625655 . collect :: < Vec < _ > > ( ) ;
626656 let mut by_id = self . pending_snapshot_map ( ) . await ;
627657 for sandbox in container_sandboxes {
@@ -1123,8 +1153,7 @@ impl DockerComputeDriver {
11231153 if let Some ( summary) = self
11241154 . find_managed_container_summary ( sandbox_id, sandbox_name)
11251155 . await ?
1126- && let Some ( sandbox) =
1127- sandbox_from_container_summary ( & summary, self . supervisor_readiness . as_ref ( ) )
1156+ && let Some ( sandbox) = sandbox_from_container_summary ( & summary)
11281157 {
11291158 self . publish_sandbox_snapshot ( sandbox) ;
11301159 }
@@ -2738,10 +2767,7 @@ fn parse_memory_limit(value: &str) -> Result<Option<i64>, Status> {
27382767 Ok ( Some ( ( amount * multiplier) . round ( ) as i64 ) )
27392768}
27402769
2741- fn sandbox_from_container_summary (
2742- summary : & ContainerSummary ,
2743- readiness : & dyn SupervisorReadiness ,
2744- ) -> Option < DriverSandbox > {
2770+ fn sandbox_from_container_summary ( summary : & ContainerSummary ) -> Option < DriverSandbox > {
27452771 let labels = summary. labels . as_ref ( ) ?;
27462772 let id = labels. get ( LABEL_SANDBOX_ID ) ?. clone ( ) ;
27472773 let name = labels. get ( LABEL_SANDBOX_NAME ) ?. clone ( ) ;
@@ -2754,28 +2780,22 @@ fn sandbox_from_container_summary(
27542780 . cloned ( )
27552781 . unwrap_or_default ( ) ;
27562782
2757- let supervisor_connected = readiness. is_supervisor_connected ( & id) ;
27582783 Some ( DriverSandbox {
27592784 id,
27602785 name : name. clone ( ) ,
27612786 namespace,
27622787 spec : None ,
2763- status : Some ( driver_status_from_summary (
2764- summary,
2765- & name,
2766- supervisor_connected,
2767- ) ) ,
2788+ status : Some ( driver_status_from_summary ( summary, & name) ) ,
27682789 workspace,
27692790 } )
27702791}
27712792
27722793fn driver_status_from_summary (
27732794 summary : & ContainerSummary ,
27742795 sandbox_name : & str ,
2775- supervisor_connected : bool ,
27762796) -> DriverSandboxStatus {
27772797 let state = summary. state . unwrap_or ( ContainerSummaryStateEnum :: EMPTY ) ;
2778- let ( ready, reason, message, deleting) = container_ready_condition ( state, supervisor_connected ) ;
2798+ let ( ready, reason, message, deleting) = container_ready_condition ( state) ;
27792799
27802800 DriverSandboxStatus {
27812801 sandbox_name : summary_container_name ( summary) . unwrap_or_else ( || sandbox_name. to_string ( ) ) ,
@@ -2795,25 +2815,10 @@ fn driver_status_from_summary(
27952815
27962816fn container_ready_condition (
27972817 state : ContainerSummaryStateEnum ,
2798- supervisor_connected : bool ,
27992818) -> ( & ' static str , & ' static str , & ' static str , bool ) {
28002819 match state {
28012820 ContainerSummaryStateEnum :: RUNNING => {
2802- if supervisor_connected {
2803- (
2804- "True" ,
2805- "SupervisorConnected" ,
2806- "Supervisor relay is live" ,
2807- false ,
2808- )
2809- } else {
2810- (
2811- "False" ,
2812- "DependenciesNotReady" ,
2813- "Container is running; waiting for supervisor relay" ,
2814- false ,
2815- )
2816- }
2821+ ( "True" , "BackendReady" , "Container is running" , false )
28172822 }
28182823 ContainerSummaryStateEnum :: CREATED => ( "False" , "Starting" , "Container created" , false ) ,
28192824 ContainerSummaryStateEnum :: RESTARTING => (
0 commit comments