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

Commit

Permalink
network: fix failed to remove network
Browse files Browse the repository at this point in the history
in create sandbox, if process error, should remove network without judge
NetNsCreated is true, since network is created by kata and should be
removed by kata, and network.Remove has judged if need to delete netns
depend on NetNsCreated

Fixes: #1920

Signed-off-by: Ace-Tang <[email protected]>
  • Loading branch information
Ace-Tang committed Jul 30, 2019
1 parent d987a30 commit 50c3e56
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,10 @@ func CreateSandbox(ctx context.Context, sandboxConfig SandboxConfig, factory Fac
return s, err
}

func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (*Sandbox, error) {
func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, factory Factory) (_ *Sandbox, err error) {
span, ctx := trace(ctx, "createSandboxFromConfig")
defer span.Finish()

var err error

// Create the sandbox.
s, err := createSandbox(ctx, sandboxConfig, factory)
if err != nil {
Expand All @@ -91,7 +89,7 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f

// network rollback
defer func() {
if err != nil && s.networkNS.NetNsCreated {
if err != nil {
s.removeNetwork()
}
}()
Expand Down

0 comments on commit 50c3e56

Please sign in to comment.