mirror of
https://github.com/containers/podman.git
synced 2025-06-26 21:07:02 +08:00
Fix error handling in pod start/stop.
Before, errors in containers would never be printed, and a generic error would only be shown. Signed-off-by: haircommander <pehunt@redhat.com> Closes: #1132 Approved by: mheon
This commit is contained in:

committed by
Atomic Bot

parent
acd28b9fc9
commit
8f48e60840
@ -78,13 +78,7 @@ func podStartCmd(c *cli.Context) error {
|
||||
ctx := getContext()
|
||||
for _, pod := range pods {
|
||||
ctr_errs, err := pod.Start(ctx)
|
||||
if err != nil {
|
||||
if lastError != nil {
|
||||
logrus.Errorf("%q", lastError)
|
||||
}
|
||||
lastError = errors.Wrapf(err, "unable to start pod %q", pod.ID())
|
||||
continue
|
||||
} else if ctr_errs != nil {
|
||||
if ctr_errs != nil {
|
||||
for ctr, err := range ctr_errs {
|
||||
if lastError != nil {
|
||||
logrus.Errorf("%q", lastError)
|
||||
@ -93,6 +87,13 @@ func podStartCmd(c *cli.Context) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
if lastError != nil {
|
||||
logrus.Errorf("%q", lastError)
|
||||
}
|
||||
lastError = errors.Wrapf(err, "unable to start pod %q", pod.ID())
|
||||
continue
|
||||
}
|
||||
fmt.Println(pod.ID())
|
||||
}
|
||||
|
||||
|
@ -79,13 +79,7 @@ func podStopCmd(c *cli.Context) error {
|
||||
for _, pod := range pods {
|
||||
// set cleanup to true to clean mounts and namespaces
|
||||
ctr_errs, err := pod.Stop(true)
|
||||
if err != nil {
|
||||
if lastError != nil {
|
||||
logrus.Errorf("%q", lastError)
|
||||
}
|
||||
lastError = errors.Wrapf(err, "unable to stop pod %q", pod.ID())
|
||||
continue
|
||||
} else if ctr_errs != nil {
|
||||
if ctr_errs != nil {
|
||||
for ctr, err := range ctr_errs {
|
||||
if lastError != nil {
|
||||
logrus.Errorf("%q", lastError)
|
||||
@ -94,6 +88,13 @@ func podStopCmd(c *cli.Context) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
if lastError != nil {
|
||||
logrus.Errorf("%q", lastError)
|
||||
}
|
||||
lastError = errors.Wrapf(err, "unable to stop pod %q", pod.ID())
|
||||
continue
|
||||
}
|
||||
fmt.Println(pod.ID())
|
||||
}
|
||||
return lastError
|
||||
|
Reference in New Issue
Block a user