Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] The phantom container's meta data #326

Closed
fuweid opened this issue Dec 14, 2017 · 1 comment
Closed

[bug] The phantom container's meta data #326

fuweid opened this issue Dec 14, 2017 · 1 comment
Labels
areas/daemon kind/bug This is bug report for project

Comments

@fuweid
Copy link
Contributor

fuweid commented Dec 14, 2017

Issue Description

If the container is still running, you still want to remove the container. OK.

The phantom container's meta.json comes to you.

Describe what happened:

The containermgr has two hooks which to clean and write the status into meta.json.

// https://github.com/alibaba/pouch/blob/master/daemon/mgr/container.go#L90 
mgr.Client.SetStopHooks(mgr.stoppedAndRelease)
mgr.Client.SetExitHooks(mgr.exitedAndRelease)

When you use to force to remove the running container, the containergmt.Remove function will remove the cache, key dir and the nameToID mapping.

 mgr.NameToID.Remove(c.Name())

 // remove meta data
if err := mgr.Store.Remove(c.meta.Key()); err != nil {
     logrus.Errorf("failed to remove container: %s meta store", c.ID())
}

// remove container cache
mgr.cache.Remove(c.ID())

Remember the Hooks? The force action will make process return exitcode. Then watch goroutine got the value from channel and call the hook stoppedAndRelease.

func (mgr *ContainerManager) stoppedAndRelease(id string, m *ctrd.Message) error {
      ....
      if err := c.Write(mgr.Store); err != nil {
      ....
      }
} 

The c.Write makes the phantom meta.json.....

Describe what you expected to happen:

The /var/lib/pouch/containers/{containerID} should be removed.

How to reproduce it (as minimally and precisely as possible):

#!/usr/bin/env bash

set -euo pipefail

name=foo

# create container
res="$(pouch create --name foo registry.hub.docker.com/library/busybox:latest)"

# get folder name
shaID="$(echo $res | grep -P '[0-9a-f]{11,}' -o)"

# start container
pouch start ${name}

# rm -f container
pouch rm -f ${name}

# still there?!
ls -al /var/lib/pouch/containers/${shaID}

Run the above script and pouch ps

Anything else we need to know?:

I think we need to upgrade the hook. :)

Environment:

  • pouch version (use pouch version):
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:
@pouchrobot pouchrobot added the kind/bug This is bug report for project label Dec 14, 2017
@fuweid
Copy link
Contributor Author

fuweid commented Dec 18, 2017

Fixed by #317

@fuweid fuweid closed this as completed Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
areas/daemon kind/bug This is bug report for project
Projects
None yet
Development

No branches or pull requests

3 participants