From 33f95b9ef82e48bd8350f6327292e55004bd6013 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 17 Aug 2018 14:21:21 -0400 Subject: 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 Closes: #1294 Approved by: rhatdan --- libpod/boltdb_state.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index de6174c10..42f029379 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -705,7 +705,11 @@ func (s *BoltState) AllContainers() ([]*Container, error) { // We just won't include the container in the // results. 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 { ctrs = append(ctrs, ctr) @@ -1655,7 +1659,7 @@ func (s *BoltState) AllPods() ([]*Pod, error) { if err := s.getPodFromDB(id, pod, podBucket); err != nil { if errors.Cause(err) != ErrNSMismatch { - return err + logrus.Errorf("Error retrieving pod %s from the database: %v", string(id), err) } } else { pods = append(pods, pod) -- cgit v1.2.3-54-g00ecf