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

Commit

Permalink
virtcontainers: revert "fix shared dir resource remaining"
Browse files Browse the repository at this point in the history
This reverts commit 8a6d383.

Don't remove all directories in the shared directory because
`docker cp` re-mounts all the mount points specified in the
config.json causing serious problems in the host.

fixes #777

Signed-off-by: Julio Montes <[email protected]>
  • Loading branch information
Julio Montes committed Sep 24, 2018
1 parent 626fb77 commit 2e797f2
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 43 deletions.
3 changes: 0 additions & 3 deletions virtcontainers/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ type agent interface {
// stopSandbox will tell the agent to stop all containers related to the Sandbox.
stopSandbox(sandbox *Sandbox) error

// cleanup will clean the resources for sandbox
cleanupSandbox(sandbox *Sandbox) error

// createContainer will tell the agent to create a container related to a Sandbox.
createContainer(sandbox *Sandbox, c *Container) (*Process, error)

Expand Down
16 changes: 4 additions & 12 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,19 +505,11 @@ func (c *Container) mountSharedDirMounts(hostSharedDir, guestSharedDir string) (
func (c *Container) unmountHostMounts() error {
for _, m := range c.mounts {
if m.HostPath != "" {
logger := c.Logger().WithField("host-path", m.HostPath)
if err := syscall.Unmount(m.HostPath, 0); err != nil {
// Unable to unmount paths could be a really big problem here
// we need to make sure cause 'less damage' if things are
// really broken. For further, we need to give admins more of
// a chance to diagnose the problem. As the rules of `fail fast`,
// here we return an error as soon as we get it.
logger.WithError(err).Warn("Could not umount")
return err
} else if err := os.RemoveAll(m.HostPath); err != nil {
// since the mounts related to the shared dir is umounted
// we need to remove the host path to avoid resource remaining
logger.WithError(err).Warn("Could not be removed")
c.Logger().WithFields(logrus.Fields{
"host-path": m.HostPath,
"error": err,
}).Warn("Could not umount")
return err
}
}
Expand Down
4 changes: 0 additions & 4 deletions virtcontainers/hyperstart_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,10 +897,6 @@ func (h *hyper) resumeContainer(sandbox *Sandbox, c Container) error {
return nil
}

func (h *hyper) cleanupSandbox(sandbox *Sandbox) error {
return nil
}

func (h *hyper) reseedRNG(data []byte) error {
// hyperstart-agent does not support reseeding
return nil
Expand Down
13 changes: 1 addition & 12 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,6 @@ func (k *kataAgent) stopSandbox(sandbox *Sandbox) error {
return k.proxy.stop(sandbox, k.state.ProxyPid)
}

func (k *kataAgent) cleanupSandbox(sandbox *Sandbox) error {
return os.RemoveAll(filepath.Join(kataHostSharedDir, sandbox.id))
}

func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error {
ociMounts := spec.Mounts

Expand Down Expand Up @@ -1072,14 +1068,7 @@ func (k *kataAgent) stopContainer(sandbox *Sandbox, c Container) error {
return err
}

if err := bindUnmountContainerRootfs(kataHostSharedDir, sandbox.id, c.id); err != nil {
return err
}

// since rootfs is umounted it's safe to remove the dir now
rootPathParent := filepath.Join(kataHostSharedDir, sandbox.id, c.id)

return os.RemoveAll(rootPathParent)
return bindUnmountContainerRootfs(kataHostSharedDir, sandbox.id, c.id)
}

func (k *kataAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
Expand Down
5 changes: 0 additions & 5 deletions virtcontainers/noop_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ func (n *noopAgent) stopSandbox(sandbox *Sandbox) error {
return nil
}

// cleanup is the Noop agent clean up resource implementation. It does nothing.
func (n *noopAgent) cleanupSandbox(sandbox *Sandbox) error {
return nil
}

// createContainer is the Noop agent Container creation implementation. It does nothing.
func (n *noopAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
return &Process{}, nil
Expand Down
7 changes: 0 additions & 7 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -1258,13 +1258,6 @@ func (s *Sandbox) stop() error {
return err
}

// vm is stopped remove the sandbox shared dir
if err := s.agent.cleanupSandbox(s); err != nil {
// cleanup resource failed shouldn't block destroy sandbox
// just raise a warning
s.Logger().WithError(err).Warnf("cleanup sandbox failed")
}

return s.setSandboxState(StateStopped)
}

Expand Down

0 comments on commit 2e797f2

Please sign in to comment.