mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-29 16:57:18 +00:00
network: fix failed to remove network
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 <aceapril@126.com>
This commit is contained in:
parent
d987a30367
commit
50c3e56aeb
@ -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