aboutsummaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-01-16 13:53:23 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-17 15:26:43 +0000
commitff77941a31352c40d13bdac3786e84e916f2bc94 (patch)
tree0fe16d41451255b55c68165426d7cf082463873a /libpod/in_memory_state.go
parent54e258bfde8f6164abf3cd0e6d8d18b1643cc91d (diff)
downloadpodman-ff77941a31352c40d13bdac3786e84e916f2bc94.tar.gz
podman-ff77941a31352c40d13bdac3786e84e916f2bc94.tar.bz2
podman-ff77941a31352c40d13bdac3786e84e916f2bc94.zip
Fix in-memory state tests
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #229 Approved by: rhatdan
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r--libpod/in_memory_state.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index 9a2b74c2a..55162e6c8 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -26,6 +26,8 @@ func NewInMemoryState() (State, error) {
state.pods = make(map[string]*Pod)
state.containers = make(map[string]*Container)
+ state.ctrDepends = make(map[string][]string)
+
state.podNameIndex = registrar.NewRegistrar()
state.ctrNameIndex = registrar.NewRegistrar()
@@ -131,13 +133,10 @@ func (s *InMemoryState) AddContainer(ctr *Container) error {
s.containers[ctr.ID()] = ctr
// Add containers this container depends on
- s.addCtrToDependsMap(ctr.ID(), ctr.config.IPCNsCtr)
- s.addCtrToDependsMap(ctr.ID(), ctr.config.MountNsCtr)
- s.addCtrToDependsMap(ctr.ID(), ctr.config.NetNsCtr)
- s.addCtrToDependsMap(ctr.ID(), ctr.config.PIDNsCtr)
- s.addCtrToDependsMap(ctr.ID(), ctr.config.UserNsCtr)
- s.addCtrToDependsMap(ctr.ID(), ctr.config.UTSNsCtr)
- s.addCtrToDependsMap(ctr.ID(), ctr.config.CgroupNsCtr)
+ depCtrs := ctr.Dependencies()
+ for _, depCtr := range depCtrs {
+ s.addCtrToDependsMap(ctr.ID(), depCtr)
+ }
return nil
}
@@ -167,13 +166,11 @@ func (s *InMemoryState) RemoveContainer(ctr *Container) error {
delete(s.ctrDepends, ctr.ID())
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.IPCNsCtr)
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.MountNsCtr)
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.NetNsCtr)
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.PIDNsCtr)
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.UserNsCtr)
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.UTSNsCtr)
- s.removeCtrFromDependsMap(ctr.ID(), ctr.config.CgroupNsCtr)
+ // Remove us from container dependencies
+ depCtrs := ctr.Dependencies()
+ for _, depCtr := range depCtrs {
+ s.removeCtrFromDependsMap(ctr.ID(), depCtr)
+ }
return nil
}
@@ -479,7 +476,7 @@ func (s *InMemoryState) removeCtrFromDependsMap(ctrID, dependsID string) {
return
}
- newArr := make([]string, len(arr), 0)
+ newArr := make([]string, 0, len(arr))
for _, id := range arr {
if id != ctrID {