diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-03-27 15:00:16 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-29 01:27:40 +0000 |
commit | 5b6f59e36cc68bf5bb2e0bd363fe005b55bf0c8f (patch) | |
tree | 9e28485f76d74a28948bd379bda019d47d150077 /libpod/boltdb_state_internal.go | |
parent | 196c3ab3a5b5c0fc803473a8c1dfa7d794a78425 (diff) | |
download | podman-5b6f59e36cc68bf5bb2e0bd363fe005b55bf0c8f.tar.gz podman-5b6f59e36cc68bf5bb2e0bd363fe005b55bf0c8f.tar.bz2 podman-5b6f59e36cc68bf5bb2e0bd363fe005b55bf0c8f.zip |
Prevent ctrs not in pods from depending on pod ctrs
Containers in pods cannot depend on containers outside of the
same pod. Make the reverse true as well - containers not in pods
cannot depend on containers in pods. This greatly simplifies our
dependency handling, as we can guarantee that removing a pod will
not encounter dependency issues.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #558
Approved by: rhatdan
Diffstat (limited to 'libpod/boltdb_state_internal.go')
-rw-r--r-- | libpod/boltdb_state_internal.go | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 9c05dcc3a..fc175fc1f 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -407,11 +407,16 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { return errors.Wrapf(ErrNoSuchCtr, "container %s depends on container %s, but it does not exist in the DB", ctr.ID(), dependsCtr) } - // If we're part of a pod, make sure the dependency is part of the same pod + depCtrPod := depCtrBkt.Get(podIDKey) if pod != nil { - depCtrPod := depCtrBkt.Get(podIDKey) + // If we're part of a pod, make sure the dependency is part of the same pod if depCtrPod == nil { - return errors.Wrapf(ErrInvalidArg, "container %s depends on container%s which is not in pod %s", ctr.ID(), dependsCtr, pod.ID()) + return errors.Wrapf(ErrInvalidArg, "container %s depends on container %s which is not in pod %s", ctr.ID(), dependsCtr, pod.ID()) + } + } else { + // If we're not part of a pod, we cannot depend on containets in a pod + if depCtrPod != nil { + return errors.Wrapf(ErrInvalidArg, "container %s depends on container %s which is in a pod - containers not in pods cannot depend on containers in pods", ctr.ID(), dependsCtr) } } |