diff options
author | Lantao Liu <lantaol@google.com> | 2018-08-28 11:52:56 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-28 11:54:07 -0700 |
commit | d8f0db9bcf2ecfaf7fb1b09d7d4cace3a8e40cc7 (patch) | |
tree | a9ba2668b904a383d9c7bfe931999afecfe91db8 /runsc/container/container.go | |
parent | f7366e4e6465530ecc1641312011fd82a94f55f8 (diff) |
runsc: unmount volume mounts when destroy container.
PiperOrigin-RevId: 210579178
Change-Id: Iae20639c5186b1a976cbff6d05bda134cd00d0da
Diffstat (limited to 'runsc/container/container.go')
-rw-r--r-- | runsc/container/container.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go index 16af66d3e..725b4d347 100644 --- a/runsc/container/container.go +++ b/runsc/container/container.go @@ -510,10 +510,6 @@ func (c *Container) Destroy() error { executeHooksBestEffort(c.Spec.Hooks.Poststop, c.State()) } - if err := os.RemoveAll(c.Root); err != nil { - log.Warningf("Failed to delete container root directory %q, err: %v", c.Root, err) - } - // If we are the first container in the sandbox, take the sandbox down // as well. if c.Sandbox != nil && c.Sandbox.IsRootContainer(c.ID) { @@ -532,6 +528,14 @@ func (c *Container) Destroy() error { } } + if err := destroyFS(c.Spec); err != nil { + return fmt.Errorf("error destroying container fs: %v", err) + } + + if err := os.RemoveAll(c.Root); err != nil && !os.IsNotExist(err) { + return fmt.Errorf("error deleting container root directory %q: %v", c.Root, err) + } + c.Status = Stopped return nil } |