Skip to content

Commit

Permalink
Fix Method of judging command execution failure
Browse files Browse the repository at this point in the history
should judge restore and run command execution failure depend both on error and
status Monitor.Wait() return

Signed-off-by: Ace-Tang <aceapril@126.com>
  • Loading branch information
Ace-Tang committed May 28, 2019
1 parent 7d11b49 commit 4e99c72
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts)
if err != nil {
return -1, err
}
return Monitor.Wait(cmd, ec)
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
}
return status, err
}

type DeleteOpts struct {
Expand Down Expand Up @@ -570,7 +574,11 @@ func (r *Runc) Restore(context context.Context, id, bundle string, opts *Restore
}
}
}
return Monitor.Wait(cmd, ec)
status, err := Monitor.Wait(cmd, ec)
if err == nil && status != 0 {
err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
}
return status, err
}

// Update updates the current container with the provided resource spec
Expand Down

0 comments on commit 4e99c72

Please sign in to comment.