-
Notifications
You must be signed in to change notification settings - Fork 348
Unmount dev shm and cleanup container when stop/remove sandbox #77
Conversation
With all my recent PRs merged, we could reliably pass 30/36 cri validation test now:
All failed tests are caused by known missing features which we are not targeting for the alpha version. The biggest blockers now are:
|
if !config.GetLinux().GetSecurityContext().GetNamespaceOptions().GetHostIpc() { | ||
if err := c.os.Unmount(getSandboxDevShm(rootDir), unix.MNT_DETACH); err != nil && os.IsNotExist(err) { | ||
glog.Errorf("failed to unmount sandbox shm: %v", err) | ||
if err := c.os.Unmount(getSandboxDevShm(rootDir), unix.MNT_DETACH); err != nil && !os.IsNotExist(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Random-Liu any reason why this needs to be umounted (if any) at sandbox stop? we do this at sandbox stop and we didn't run into any issues yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@runcom I feel like either stop or remove is ok.
The reason why we unmount in sandbox stop now is:
- I tried docker, after
docker stop
, shm is unmounted. - Kubelet may garbage collect (remove) sandbox long after sandbox is stopped, we may not want to keep the shm during that. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, thanks @Random-Liu !!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@runcom Np. :)
pkg/os/os.go
Outdated
func (RealOS) Unmount(target string, flags int) error { | ||
if mounted, err := mount.Mounted(target); err != nil || !mounted { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be careful with the check here, if shm path is under /var/run/...
but the mount in the /proc/self/mountinfo
is in the form of /run/...
you'll get mounted = false, err = nil
.
For instance, in CRI-O we store shm under /var/run/CONTID/shm
but if you pass that to mount.Mounted
it'll say that's not mounted because /proc/self/mountinfo
only contains /run/CONTID/shm
and that doesn't match.
We do resolve the symlink first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We put everything in /var/lib
now. :p May need to consider the directory structure more later.
Will add a TODO here to take care of this in the future.
ecaafe0
to
91638cf
Compare
Signed-off-by: Lantao Liu <lantaol@google.com>
Signed-off-by: Lantao Liu <lantaol@google.com>
Signed-off-by: Lantao Liu <lantaol@google.com>
91638cf
to
57b8b43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! LGTM
Apply LGTM based on #77 (review). |
Unmount dev shm and cleanup container when stop/remove sandbox
Cherry-pick: Forcibly stop running containers before removal
Based on #73. The last 2 commits are new.
/dev/shm
when stop sandbox.