Track container removal in state
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
6bbdbdeed8
commit
0c386f74f9
1 changed files with 12 additions and 2 deletions
|
@ -59,7 +59,7 @@ type sandbox struct {
|
|||
name string
|
||||
logDir string
|
||||
labels map[string]string
|
||||
containers []*oci.Container
|
||||
containers map[string]*oci.Container
|
||||
}
|
||||
|
||||
func (s *Server) addSandbox(sb *sandbox) {
|
||||
|
@ -72,7 +72,11 @@ func (s *Server) hasSandbox(name string) bool {
|
|||
}
|
||||
|
||||
func (s *sandbox) addContainer(c *oci.Container) {
|
||||
s.containers = append(s.containers, c)
|
||||
s.containers[c.Name()] = c
|
||||
}
|
||||
|
||||
func (s *sandbox) removeContainer(c *oci.Container) {
|
||||
delete(s.containers, c.Name())
|
||||
}
|
||||
|
||||
func (s *Server) addContainer(c *oci.Container) {
|
||||
|
@ -80,3 +84,9 @@ func (s *Server) addContainer(c *oci.Container) {
|
|||
sandbox.addContainer(c)
|
||||
s.state.containers[c.Name()] = c
|
||||
}
|
||||
|
||||
func (s *Server) removeContainer(c *oci.Container) {
|
||||
sandbox := s.state.sandboxes[c.Sandbox()]
|
||||
sandbox.removeContainer(c)
|
||||
delete(s.state.containers, c.Name())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue