mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-14 15:44:58 +00:00
Merge pull request #1969 from bergwolf/detach
do not hotplug network device when stopping sandbox
This commit is contained in:
commit
0bf48dca65
@ -1480,22 +1480,16 @@ func (n *Network) PostAdd(ctx context.Context, ns *NetworkNamespace, hotplug boo
|
|||||||
|
|
||||||
// Remove network endpoints in the network namespace. It also deletes the network
|
// Remove network endpoints in the network namespace. It also deletes the network
|
||||||
// namespace in case the namespace has been created by us.
|
// namespace in case the namespace has been created by us.
|
||||||
func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor, hotunplug bool) error {
|
func (n *Network) Remove(ctx context.Context, ns *NetworkNamespace, hypervisor hypervisor) error {
|
||||||
span, _ := n.trace(ctx, "remove")
|
span, _ := n.trace(ctx, "remove")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
for _, endpoint := range ns.Endpoints {
|
for _, endpoint := range ns.Endpoints {
|
||||||
// Detach for an endpoint should enter the network namespace
|
// Detach for an endpoint should enter the network namespace
|
||||||
// if required.
|
// if required.
|
||||||
networkLogger().WithField("endpoint-type", endpoint.Type()).WithField("hotunplug", hotunplug).Info("Detaching endpoint")
|
networkLogger().WithField("endpoint-type", endpoint.Type()).Info("Detaching endpoint")
|
||||||
if hotunplug {
|
if err := endpoint.Detach(ns.NetNsCreated, ns.NetNsPath); err != nil {
|
||||||
if err := endpoint.HotDetach(hypervisor, ns.NetNsCreated, ns.NetNsPath); err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := endpoint.Detach(ns.NetNsCreated, ns.NetNsPath); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,7 +862,7 @@ func (s *Sandbox) removeNetwork() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.network.Remove(s.ctx, &s.networkNS, s.hypervisor, s.factory != nil)
|
return s.network.Remove(s.ctx, &s.networkNS, s.hypervisor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Sandbox) generateNetInfo(inf *vcTypes.Interface) (NetworkInfo, error) {
|
func (s *Sandbox) generateNetInfo(inf *vcTypes.Interface) (NetworkInfo, error) {
|
||||||
@ -1473,11 +1473,6 @@ func (s *Sandbox) Stop(force bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the network.
|
|
||||||
if err := s.removeNetwork(); err != nil && !force {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := s.stopVM(); err != nil && !force {
|
if err := s.stopVM(); err != nil && !force {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1486,6 +1481,11 @@ func (s *Sandbox) Stop(force bool) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the network.
|
||||||
|
if err := s.removeNetwork(); err != nil && !force {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if err := s.storeSandbox(); err != nil {
|
if err := s.storeSandbox(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user