@@ -674,6 +674,14 @@ impl DockerComputeDriver {
674674 sandbox_id : & str ,
675675 sandbox_name : & str ,
676676 ) -> Result < Option < DriverSandbox > , Status > {
677+ let pending = self . pending_snapshot ( sandbox_id, sandbox_name) . await ;
678+ if pending
679+ . as_ref ( )
680+ . is_some_and ( pending_sandbox_has_provisioning_failure)
681+ {
682+ return Ok ( pending) ;
683+ }
684+
677685 let container = self
678686 . find_managed_container_summary ( sandbox_id, sandbox_name)
679687 . await ?;
@@ -683,7 +691,7 @@ impl DockerComputeDriver {
683691 return Ok ( Some ( sandbox) ) ;
684692 }
685693
686- Ok ( self . pending_snapshot ( sandbox_id , sandbox_name ) . await )
694+ Ok ( pending )
687695 }
688696
689697 async fn current_snapshots ( & self ) -> Result < Vec < DriverSandbox > , Status > {
@@ -692,10 +700,11 @@ impl DockerComputeDriver {
692700 . iter ( )
693701 . filter_map ( sandbox_from_container_summary)
694702 . collect :: < Vec < _ > > ( ) ;
695- let mut by_id = self . pending_snapshot_map ( ) . await ;
696- for sandbox in container_sandboxes {
697- by_id. insert ( sandbox. id . clone ( ) , sandbox) ;
698- }
703+ let mut by_id = container_sandboxes
704+ . into_iter ( )
705+ . map ( |sandbox| ( sandbox. id . clone ( ) , sandbox) )
706+ . collect :: < HashMap < _ , _ > > ( ) ;
707+ merge_pending_sandbox_snapshots ( & mut by_id, self . pending_snapshot_map ( ) . await ) ;
699708 let mut sandboxes = by_id. into_values ( ) . collect :: < Vec < _ > > ( ) ;
700709 sandboxes. sort_by ( |left, right| left. id . cmp ( & right. id ) ) ;
701710 Ok ( sandboxes)
@@ -1828,6 +1837,33 @@ fn pending_sandbox_matches(sandbox: &DriverSandbox, sandbox_id: &str, sandbox_na
18281837 || ( !sandbox_name. is_empty ( ) && sandbox. name == sandbox_name)
18291838}
18301839
1840+ /// A pending sandbox holds either the ordinary in-progress snapshot or the
1841+ /// explicit error published by its provisioning task. The latter is more
1842+ /// informative than a transient Docker state observed while that task cleans
1843+ /// up a failed start, so it must win during snapshot reconciliation.
1844+ fn pending_sandbox_has_provisioning_failure ( sandbox : & DriverSandbox ) -> bool {
1845+ sandbox. status . as_ref ( ) . is_some_and ( |status| {
1846+ status. conditions . iter ( ) . any ( |condition| {
1847+ condition. r#type == "Ready"
1848+ && condition. status . eq_ignore_ascii_case ( "false" )
1849+ && condition. reason != "Starting"
1850+ } )
1851+ } )
1852+ }
1853+
1854+ fn merge_pending_sandbox_snapshots (
1855+ snapshots : & mut HashMap < String , DriverSandbox > ,
1856+ pending : HashMap < String , DriverSandbox > ,
1857+ ) {
1858+ for ( sandbox_id, sandbox) in pending {
1859+ if pending_sandbox_has_provisioning_failure ( & sandbox) {
1860+ snapshots. insert ( sandbox_id, sandbox) ;
1861+ } else {
1862+ snapshots. entry ( sandbox_id) . or_insert ( sandbox) ;
1863+ }
1864+ }
1865+ }
1866+
18311867fn provisioning_condition ( ) -> DriverCondition {
18321868 DriverCondition {
18331869 r#type : "Ready" . to_string ( ) ,
0 commit comments