Skip to content

Commit

Permalink
Merge pull request #3212 from rhatdan/error
Browse files Browse the repository at this point in the history
Fix race condition
  • Loading branch information
openshift-merge-robot committed May 10, 2021
2 parents 22fc573 + 79bdcca commit 135d63d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion run_linux.go
Expand Up @@ -851,6 +851,7 @@ func runUsingRuntime(isolation define.Isolation, options RunOptions, configureNe
if err != nil {
return 1, errors.Wrapf(err, "error parsing pid %s as a number", string(pidValue))
}
stopped := false
var reaping sync.WaitGroup
reaping.Add(1)
go func() {
Expand All @@ -861,6 +862,7 @@ func runUsingRuntime(isolation define.Isolation, options RunOptions, configureNe
wstatus = 0
logrus.Errorf("error waiting for container child process %d: %v\n", pid, err)
}
stopped = true
}()

if configureNetwork {
Expand Down Expand Up @@ -892,7 +894,6 @@ func runUsingRuntime(isolation define.Isolation, options RunOptions, configureNe
if err != nil {
return 1, errors.Wrapf(err, "error from %s starting container", runtime)
}
stopped := false
defer func() {
if !stopped {
if err2 := kill.Run(); err2 != nil {
Expand All @@ -911,6 +912,10 @@ func runUsingRuntime(isolation define.Isolation, options RunOptions, configureNe
stat.Stderr = os.Stderr
stateOutput, err := stat.Output()
if err != nil {
if stopped {
// container exited
break
}
return 1, errors.Wrapf(err, "error reading container state from %s (got output: %q)", runtime, string(stateOutput))
}
if err = json.Unmarshal(stateOutput, &state); err != nil {
Expand Down

0 comments on commit 135d63d

Please sign in to comment.