@@ -1970,18 +1970,27 @@ RUN date --utc > /root/date.txt`, testImageAlpine),
1970
1970
envbuilderEnv ("GIT_URL" , srv .URL ),
1971
1971
envbuilderEnv ("CACHE_REPO" , notRegURL ),
1972
1972
envbuilderEnv ("PUSH_IMAGE" , "1" ),
1973
- envbuilderEnv ("INIT_SCRIPT" , " exit \\ ${ENVBUILDER_EXIT_CODE:-254}" ),
1973
+ envbuilderEnv ("INIT_SCRIPT" , ` exit ${ENVBUILDER_EXIT_CODE:-254}` ),
1974
1974
}})
1975
1975
require .NoError (t , err )
1976
1976
1977
1977
// Then: envbuilder should fail with a descriptive status code.
1978
1978
client , err := client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
1979
1979
require .NoError (t , err )
1980
1980
defer client .Close ()
1981
- // Get the container exit status.
1982
- status , err := client .ContainerInspect (context .Background (), ctrID )
1983
- require .NoError (t , err )
1984
- require .Equal (t , 254 , status .State .ExitCode )
1981
+ // Get the container exit status. Note that the container may take a while to fully exit
1982
+ // so we need to retry a couple of times.
1983
+ require .Eventually (t , func () bool {
1984
+ status , err := client .ContainerInspect (context .Background (), ctrID )
1985
+ if ! assert .NoError (t , err ) {
1986
+ return false
1987
+ }
1988
+ if status .State .Running {
1989
+ t .Logf ("container %q still running" , ctrID )
1990
+ return false
1991
+ }
1992
+ return assert .Equal (t , status .State .ExitCode , 254 , "unexpected exit code" )
1993
+ }, 10 * time .Second , time .Second , "unexpected exit code" )
1985
1994
})
1986
1995
1987
1996
t .Run ("CacheAndPushDevcontainerFeatures" , func (t * testing.T ) {
0 commit comments