diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/boltdb_state_linux.go | 31 | ||||
-rw-r--r-- | libpod/boltdb_state_unsupported.go | 11 |
2 files changed, 31 insertions, 11 deletions
diff --git a/libpod/boltdb_state_linux.go b/libpod/boltdb_state_linux.go index 7c0e08fb3..9c0e2b348 100644 --- a/libpod/boltdb_state_linux.go +++ b/libpod/boltdb_state_linux.go @@ -13,6 +13,24 @@ import ( "github.com/sirupsen/logrus" ) +// parseNetNSBoltData sets ctr.state.NetNS, if any, from netNSBytes. +// Returns true if the data is valid. +func parseNetNSBoltData(ctr *Container, netNSBytes []byte) bool { + // The container may not have a network namespace, so it's OK if this is + // nil + if netNSBytes != nil { + nsPath := string(netNSBytes) + netNS, err := joinNetNS(nsPath) + if err == nil { + ctr.state.NetNS = netNS + } else { + logrus.Errorf("error joining network namespace for container %s", ctr.ID()) + return false + } + } + return true +} + func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.Bucket) error { valid := true ctrBkt := ctrsBkt.Bucket(id) @@ -47,17 +65,8 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt. return errors.Wrapf(err, "error unmarshalling container %s state", string(id)) } - // The container may not have a network namespace, so it's OK if this is - // nil - if netNSBytes != nil { - nsPath := string(netNSBytes) - netNS, err := joinNetNS(nsPath) - if err == nil { - ctr.state.NetNS = netNS - } else { - logrus.Errorf("error joining network namespace for container %s", ctr.ID()) - valid = false - } + if !parseNetNSBoltData(ctr, netNSBytes) { + valid = false } // Get the lock diff --git a/libpod/boltdb_state_unsupported.go b/libpod/boltdb_state_unsupported.go index 8d3749881..f6faaa378 100644 --- a/libpod/boltdb_state_unsupported.go +++ b/libpod/boltdb_state_unsupported.go @@ -4,8 +4,19 @@ package libpod import ( "github.com/boltdb/bolt" + "github.com/sirupsen/logrus" ) +// parseNetNSBoltData sets ctr.state.NetNS, if any, from netNSBytes. +// Returns true if the data is valid. +func parseNetNSBoltData(ctr *Container, netNSBytes []byte) bool { + if netNSBytes != nil { + logrus.Errorf("error loading %s: network namespaces are not supported on this platform", ctr.ID()) + return false + } + return true +} + func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.Bucket) error { return ErrNotImplemented } |