Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: unmount host mounts if container can't be created
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Julio Montes committed Oct 11, 2019
1 parent c7b4c5e commit eca7bd2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,12 @@ func (c *Container) rollbackFailingContainerCreation() {
if err := c.removeDrive(); err != nil {
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 {
Expand Down

0 comments on commit eca7bd2

Please sign in to comment.