summaryrefslogtreecommitdiffhomepage
path: root/runsc/container/container.go
diff options
context:
space:
mode:
authorIan Lewis <ianlewis@google.com>2018-10-21 19:41:44 -0700
committerShentubot <shentubot@google.com>2018-10-21 19:42:32 -0700
commitc2c0f9cb7e8320de06ef280c6184bb6aeda71627 (patch)
treee5f1d803900f54355b20f99d74817d0e292eb02c /runsc/container/container.go
parentd7c11c741752813e56b7d8726a575a520260c56a (diff)
Updated cleanup code to be more explicit about ignoring errors.
Errors are shown as being ignored by assigning to the blank identifier. PiperOrigin-RevId: 218103819 Change-Id: I7cc7b9d8ac503a03de5504ebdeb99ed30a531cf2
Diffstat (limited to 'runsc/container/container.go')
-rw-r--r--runsc/container/container.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go
index cb4c9b5c1..9da25a863 100644
--- a/runsc/container/container.go
+++ b/runsc/container/container.go
@@ -262,7 +262,9 @@ func Create(id string, spec *specs.Spec, conf *boot.Config, bundleDir, consoleSo
Status: Creating,
Owner: os.Getenv("USER"),
}
- cu := specutils.MakeCleanup(func() { c.Destroy() })
+ // The Cleanup object cleans up partially created containers when an error occurs.
+ // Any errors occuring during cleanup itself are ignored.
+ cu := specutils.MakeCleanup(func() { _ = c.Destroy() })
defer cu.Clean()
// If the metadata annotations indicate that this container should be
@@ -424,6 +426,8 @@ func Run(id string, spec *specs.Spec, conf *boot.Config, bundleDir, consoleSocke
if err != nil {
return 0, fmt.Errorf("error creating container: %v", err)
}
+ // Clean up partially created container if an error ocurrs.
+ // Any errors returned by Destroy() itself are ignored.
defer c.Destroy()
if err := c.Start(conf); err != nil {