Make failure to retrieve individual ctrs/pods nonfatal

This ensures that we can still use Podman even if a container or
pod with bad config JSON makes it into the state. We still can't
remove these containers, but at least we can do our best to make
things usable.

Signed-off-by: Matthew Heon <matthew.heon@gmail.com>

Closes: #1294
Approved by: rhatdan
This commit is contained in:
Matthew Heon 2018-08-17 14:21:21 -04:00 committed by Atomic Bot
parent 76915d5ffd
commit 33f95b9ef8
1 changed files with 6 additions and 2 deletions

View File

@ -705,7 +705,11 @@ func (s *BoltState) AllContainers() ([]*Container, error) {
// We just won't include the container in the // We just won't include the container in the
// results. // results.
if errors.Cause(err) != ErrNSMismatch { if errors.Cause(err) != ErrNSMismatch {
return err // Even if it's not an NS mismatch, it's
// not worth erroring over.
// If we do, a single bad container JSON
// could render libpod unusable.
logrus.Errorf("Error retrieving container %s from the database: %v", string(id), err)
} }
} else { } else {
ctrs = append(ctrs, ctr) ctrs = append(ctrs, ctr)
@ -1655,7 +1659,7 @@ func (s *BoltState) AllPods() ([]*Pod, error) {
if err := s.getPodFromDB(id, pod, podBucket); err != nil { if err := s.getPodFromDB(id, pod, podBucket); err != nil {
if errors.Cause(err) != ErrNSMismatch { if errors.Cause(err) != ErrNSMismatch {
return err logrus.Errorf("Error retrieving pod %s from the database: %v", string(id), err)
} }
} else { } else {
pods = append(pods, pod) pods = append(pods, pod)