mirror of
https://github.com/containers/podman.git
synced 2025-10-19 12:12:36 +08:00
Split parseNetNSBoltData from BoltState.getContainerFromDB
This is the actual platform-specific part of getContainerFromDB. Factor it out, unchanged, on Linux. On other platforms, introduce a stub which fails if any data exists; this stub is not yet called. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1115 Approved by: rhatdan
This commit is contained in:

committed by
Atomic Bot

parent
24fe6e950c
commit
eba6bf0018
@ -13,6 +13,24 @@ import (
|
|||||||
"github.com/sirupsen/logrus"
|
"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 {
|
func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.Bucket) error {
|
||||||
valid := true
|
valid := true
|
||||||
ctrBkt := ctrsBkt.Bucket(id)
|
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))
|
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
|
if !parseNetNSBoltData(ctr, netNSBytes) {
|
||||||
// nil
|
valid = false
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the lock
|
// Get the lock
|
||||||
|
@ -4,8 +4,19 @@ package libpod
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/boltdb/bolt"
|
"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 {
|
func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt.Bucket) error {
|
||||||
return ErrNotImplemented
|
return ErrNotImplemented
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user