mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 08:47:56 +00:00
Merge pull request #1921 from Ace-Tang/fix-remove-network
network: fix failed to remove network
This commit is contained in:
commit
14474a49a2
@ -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 {
|
||||
@ -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()
|
||||
}
|
||||
}()
|
||||
|
Loading…
Reference in New Issue
Block a user