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

Commit

Permalink
virtcontainers: Check the correct error variable for sandbox creation
Browse files Browse the repository at this point in the history
This PR makes the deferred func check the correct error variable.

Fixes #2759

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
  • Loading branch information
tedyu committed Jun 10, 2020
1 parent 517ad43 commit 2c34263
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions virtcontainers/sandbox.go
Expand Up @@ -505,7 +505,7 @@ func createSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
return s, nil
}

func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (*Sandbox, error) {
func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (sb *Sandbox, retErr error) {
span, ctx := trace(ctx, "newSandbox")
defer span.Finish()

Expand Down Expand Up @@ -547,8 +547,8 @@ func newSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Factor
}

defer func() {
if err != nil {
s.Logger().WithError(err).WithField("sandboxid", s.id).Error("Create new sandbox failed")
if retErr != nil {
s.Logger().WithError(retErr).WithField("sandboxid", s.id).Error("Create new sandbox failed")
globalSandboxList.removeSandbox(s.id)
s.newStore.Destroy(s.id)
}
Expand Down

0 comments on commit 2c34263

Please sign in to comment.