Skip to content

Commit

Permalink
Podman-remote run should wait for exit code
Browse files Browse the repository at this point in the history
This change matches what is happening on the podman local side
and should eliminate a race condition.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Sep 4, 2019
1 parent f1a3e02 commit 5816230
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions pkg/adapter/containers_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,33 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode
results := shared.NewIntermediateLayer(&c.PodmanCommand, true)
cid, err := iopodman.CreateContainer().Call(r.Conn, results.MakeVarlink())
if err != nil {
return 0, err
return exitCode, err
}
if c.Bool("detach") {
_, err := iopodman.StartContainer().Call(r.Conn, cid)
fmt.Println(cid)
return 0, err
return exitCode, err
}
errChan, err := r.attach(ctx, os.Stdin, os.Stdout, cid, true, c.String("detach-keys"))
if err != nil {
return 0, err
return exitCode, err
}
err = <-errChan
if err != nil {
return exitCode, err
}
if ecode, err := iopodman.WaitContainer().Call(r.Conn, cid, 0); err == nil {

exitCode = int(ecode)
}
finalError := <-errChan
return 0, finalError

if c.IsSet("rm") {
if _, err1 := iopodman.RemoveContainer().Call(r.Conn, cid, false, false); err != nil {
logrus.Errorf("Error removing container %s: %v", cid, err1)
}
}
return exitCode, err

}

func ReadExitFile(runtimeTmp, ctrID string) (int, error) {
Expand Down

0 comments on commit 5816230

Please sign in to comment.