Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup network to make sure physical interfaces are restores back to original host driver. #8647

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/runtime/virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,19 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
}
}()

// Create the sandbox network
if err = s.createNetwork(ctx); err != nil {
return nil, err
}

// network rollback
defer func() {
if err != nil {
virtLog.Info("Removing network after failure in createSandbox")
s.removeNetwork(ctx)
}
}()

// Create the sandbox network
if err = s.createNetwork(ctx); err != nil {
return nil, err
}

// Set the sandbox host cgroups.
if err := s.setupResourceController(); err != nil {
return nil, err
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/virtcontainers/network_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,12 @@ func (n *LinuxNetwork) RemoveEndpoints(ctx context.Context, s *Sandbox, endpoint
}

if err := n.removeSingleEndpoint(ctx, s, ep, hotplug); err != nil {
return err
// Log the error instead of returning right away
// Proceed to remove the next endpoint so as to clean the network setup as
// much as possible.
// This is crucial for physical endpoints as we want to bind back the physical
// interface to its original host driver.
networkLogger().Warnf("Error removing endpoint %v : %v", ep.Name(), err)
}
}

Expand Down