Skip to content

Commit 4e99c72

Browse files
committed
Fix Method of judging command execution failure
should judge restore and run command execution failure depend both on error and status Monitor.Wait() return Signed-off-by: Ace-Tang <[email protected]>
1 parent 7d11b49 commit 4e99c72

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

runc.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ func (r *Runc) Run(context context.Context, id, bundle string, opts *CreateOpts)
275275
if err != nil {
276276
return -1, err
277277
}
278-
return Monitor.Wait(cmd, ec)
278+
status, err := Monitor.Wait(cmd, ec)
279+
if err == nil && status != 0 {
280+
err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
281+
}
282+
return status, err
279283
}
280284

281285
type DeleteOpts struct {
@@ -570,7 +574,11 @@ func (r *Runc) Restore(context context.Context, id, bundle string, opts *Restore
570574
}
571575
}
572576
}
573-
return Monitor.Wait(cmd, ec)
577+
status, err := Monitor.Wait(cmd, ec)
578+
if err == nil && status != 0 {
579+
err = fmt.Errorf("%s did not terminate sucessfully", cmd.Args[0])
580+
}
581+
return status, err
574582
}
575583

576584
// Update updates the current container with the provided resource spec

0 commit comments

Comments
 (0)