virtcontainers: unmount host mounts if container can't be created

Mount points, like `resolv.conf` and `hostname` are left in the
host when the cgroup creation fails.
Use `unmountHostMounts()` and `bindUnmountContainerRootfs()` in the rollback
function that is called when container's creation fails.

fixes #2108

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2019-10-10 20:44:07 +00:00
parent c7b4c5eab9
commit eca7bd2705

View File

@ -857,6 +857,12 @@ func (c *Container) rollbackFailingContainerCreation() {
if err := c.removeDrive(); err != nil { if err := c.removeDrive(); err != nil {
c.Logger().WithError(err).Error("rollback failed removeDrive()") c.Logger().WithError(err).Error("rollback failed removeDrive()")
} }
if err := c.unmountHostMounts(); err != nil {
c.Logger().WithError(err).Error("rollback failed unmountHostMounts()")
}
if err := bindUnmountContainerRootfs(c.ctx, kataHostSharedDir(), c.sandbox.id, c.id); err != nil {
c.Logger().WithError(err).Error("rollback failed bindUnmountContainerRootfs()")
}
} }
func (c *Container) checkBlockDeviceSupport() bool { func (c *Container) checkBlockDeviceSupport() bool {