diff --git a/virtcontainers/sandbox.go b/virtcontainers/sandbox.go index 9f2e30f488..7c17dd3851 100644 --- a/virtcontainers/sandbox.go +++ b/virtcontainers/sandbox.go @@ -1,4 +1,5 @@ // Copyright (c) 2016 Intel Corporation +// Copyright (c) 2020 Adobe Inc. // // SPDX-License-Identifier: Apache-2.0 // @@ -1166,6 +1167,11 @@ func (s *Sandbox) CreateContainer(contConfig ContainerConfig) (VCContainer, erro defer func() { // Rollback if error happens. if err != nil { + s.Logger().Warningf("Container %q could not be created, stopping it", contConfig.ID) + if err = c.stop(false); err != nil { // Should this be a force stop? + s.Logger().WithError(err).WithField("container-id", c.id).WithField("sandboxid", s.id).Warning("Could not delete container") + } + s.Logger().WithField("container-id", c.id).WithField("sandboxid", s.id).Info("Container was stopped. Removing from sandbox store") s.removeContainer(c.id) } }()