summaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-03-27 15:00:16 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-29 01:27:40 +0000
commit5b6f59e36cc68bf5bb2e0bd363fe005b55bf0c8f (patch)
tree9e28485f76d74a28948bd379bda019d47d150077 /libpod/in_memory_state.go
parent196c3ab3a5b5c0fc803473a8c1dfa7d794a78425 (diff)
downloadpodman-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/in_memory_state.go')
-rw-r--r--libpod/in_memory_state.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index a38e080b7..386ace5b6 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -126,9 +126,12 @@ func (s *InMemoryState) AddContainer(ctr *Container) error {
// But in-memory state is intended purely for testing and not production
// use, so this should be fine.
depCtrs := ctr.Dependencies()
- for _, depCtr := range depCtrs {
- if _, ok := s.containers[depCtr]; !ok {
- return errors.Wrapf(ErrNoSuchCtr, "cannot depend on nonexistent container %s", depCtr)
+ for _, depID := range depCtrs {
+ depCtr, ok := s.containers[depID]
+ if !ok {
+ return errors.Wrapf(ErrNoSuchCtr, "cannot depend on nonexistent container %s", depID)
+ } else if depCtr.config.Pod != "" {
+ return errors.Wrapf(ErrInvalidArg, "cannot depend on container in a pod if not part of same pod")
}
}