mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
virtcontainers: revert "fix shared dir resource remaining"
This reverts commit 8a6d383715
.
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 <julio.montes@intel.com>
This commit is contained in:
parent
e39a734184
commit
9e606b3da8
@ -163,9 +163,6 @@ type agent interface {
|
|||||||
// stopSandbox will tell the agent to stop all containers related to the Sandbox.
|
// stopSandbox will tell the agent to stop all containers related to the Sandbox.
|
||||||
stopSandbox(sandbox *Sandbox) error
|
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 will tell the agent to create a container related to a Sandbox.
|
||||||
createContainer(sandbox *Sandbox, c *Container) (*Process, error)
|
createContainer(sandbox *Sandbox, c *Container) (*Process, error)
|
||||||
|
|
||||||
|
@ -507,19 +507,11 @@ func (c *Container) unmountHostMounts() error {
|
|||||||
span, _ := c.trace("unmount")
|
span, _ := c.trace("unmount")
|
||||||
span.SetTag("host-path", m.HostPath)
|
span.SetTag("host-path", m.HostPath)
|
||||||
|
|
||||||
logger := c.Logger().WithField("host-path", m.HostPath)
|
|
||||||
if err := syscall.Unmount(m.HostPath, 0); err != nil {
|
if err := syscall.Unmount(m.HostPath, 0); err != nil {
|
||||||
// Unable to unmount paths could be a really big problem here
|
c.Logger().WithFields(logrus.Fields{
|
||||||
// we need to make sure cause 'less damage' if things are
|
"host-path": m.HostPath,
|
||||||
// really broken. For further, we need to give admins more of
|
"error": err,
|
||||||
// a chance to diagnose the problem. As the rules of `fail fast`,
|
}).Warn("Could not umount")
|
||||||
// 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")
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -953,10 +953,6 @@ func (h *hyper) resumeContainer(sandbox *Sandbox, c Container) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *hyper) cleanupSandbox(sandbox *Sandbox) error {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (h *hyper) reseedRNG(data []byte) error {
|
func (h *hyper) reseedRNG(data []byte) error {
|
||||||
// hyperstart-agent does not support reseeding
|
// hyperstart-agent does not support reseeding
|
||||||
return nil
|
return nil
|
||||||
|
@ -670,10 +670,6 @@ func (k *kataAgent) stopSandbox(sandbox *Sandbox) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
func (k *kataAgent) replaceOCIMountSource(spec *specs.Spec, guestMounts []Mount) error {
|
||||||
ociMounts := spec.Mounts
|
ociMounts := spec.Mounts
|
||||||
|
|
||||||
@ -1167,14 +1163,7 @@ func (k *kataAgent) stopContainer(sandbox *Sandbox, c Container) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := bindUnmountContainerRootfs(k.ctx, kataHostSharedDir, sandbox.id, c.id); err != nil {
|
return bindUnmountContainerRootfs(k.ctx, kataHostSharedDir, sandbox.id, c.id)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *kataAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
|
func (k *kataAgent) signalProcess(c *Container, processID string, signal syscall.Signal, all bool) error {
|
||||||
|
@ -58,11 +58,6 @@ func (n *noopAgent) stopSandbox(sandbox *Sandbox) error {
|
|||||||
return nil
|
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.
|
// createContainer is the Noop agent Container creation implementation. It does nothing.
|
||||||
func (n *noopAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
|
func (n *noopAgent) createContainer(sandbox *Sandbox, c *Container) (*Process, error) {
|
||||||
return &Process{}, nil
|
return &Process{}, nil
|
||||||
|
@ -1455,13 +1455,6 @@ func (s *Sandbox) stop() error {
|
|||||||
return err
|
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)
|
return s.setSandboxState(StateStopped)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user