mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-27 19:35:32 +00:00
network: Move up defer block tp cleanup network
Move the defer for cleaning up network before the call to add network. This way if any change made by add network is reverted by in case of failure. This is particulary important for physical network interfaces as with this step we make sure that driver for the physical interface is reverted back to the original host driver. Without this the physical network iterface will remain bound to vfio. Fixes: #8646 Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
This commit is contained in:
parent
61ce7455c5
commit
b005cda689
@ -70,18 +70,19 @@ func createSandboxFromConfig(ctx context.Context, sandboxConfig SandboxConfig, f
|
||||
}
|
||||
}()
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// network rollback
|
||||
defer func() {
|
||||
if err != nil {
|
||||
s.removeNetwork(ctx)
|
||||
}
|
||||
}()
|
||||
|
||||
// Set the sandbox host cgroups.
|
||||
if err := s.setupResourceController(); err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user