mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
checkpoint,restore,list: don't call fatal
There is a mix of styles when handling CLI commands. In most cases we return an error, which is handled from app.Run in main.go (it calls fatal if there is an error). In a few cases, though, we call fatal(err) from random places. Let's be consistent and always return an error. The only exception is runc exec, which needs to exit with a particular exit code. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
+7
-4
@@ -109,7 +109,10 @@ using the runc checkpoint command.`,
|
||||
logrus.Warn("runc checkpoint is untested with rootless containers")
|
||||
}
|
||||
|
||||
options := criuOptions(context)
|
||||
options, err := criuOptions(context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := setEmptyNsMask(context, options); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -124,10 +127,10 @@ using the runc checkpoint command.`,
|
||||
},
|
||||
}
|
||||
|
||||
func criuOptions(context *cli.Context) *libcontainer.CriuOpts {
|
||||
func criuOptions(context *cli.Context) (*libcontainer.CriuOpts, error) {
|
||||
imagePath, parentPath, err := prepareImagePaths(context)
|
||||
if err != nil {
|
||||
fatal(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &libcontainer.CriuOpts{
|
||||
@@ -145,5 +148,5 @@ func criuOptions(context *cli.Context) *libcontainer.CriuOpts {
|
||||
StatusFd: context.Int("status-fd"),
|
||||
LsmProfile: context.String("lsm-profile"),
|
||||
LsmMountContext: context.String("lsm-mount-context"),
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user