mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-05 19:47:53 +00:00
network: always assign sandbox networkNS
For vm factory, we also need netns to be set otherwise we fail to create new VMs in `s.network.run`. Fixes: #681 Signed-off-by: Peng Tao <bergwolf@gmail.com>
This commit is contained in:
parent
b982373813
commit
5e849f143b
@ -54,11 +54,7 @@ func (n *defNetwork) add(s *Sandbox) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
s.networkNS = NetworkNamespace{
|
s.networkNS.Endpoints = endpoints
|
||||||
NetNsPath: s.config.NetworkConfig.NetNSPath,
|
|
||||||
NetNsCreated: s.config.NetworkConfig.NetNsCreated,
|
|
||||||
Endpoints: endpoints,
|
|
||||||
}
|
|
||||||
|
|
||||||
err = doNetNS(s.config.NetworkConfig.NetNSPath, func(_ ns.NetNS) error {
|
err = doNetNS(s.config.NetworkConfig.NetNSPath, func(_ ns.NetNS) error {
|
||||||
for _, endpoint := range s.networkNS.Endpoints {
|
for _, endpoint := range s.networkNS.Endpoints {
|
||||||
|
@ -973,20 +973,23 @@ func (s *Sandbox) createNetwork() error {
|
|||||||
span, _ := s.trace("createNetwork")
|
span, _ := s.trace("createNetwork")
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
|
s.networkNS = NetworkNamespace{
|
||||||
|
NetNsPath: s.config.NetworkConfig.NetNSPath,
|
||||||
|
NetNsCreated: s.config.NetworkConfig.NetNsCreated,
|
||||||
|
}
|
||||||
|
|
||||||
// In case there is a factory, the network should be handled
|
// In case there is a factory, the network should be handled
|
||||||
// through some calls at the API level, in order to add or
|
// through some calls at the API level, in order to add or
|
||||||
// remove interfaces and routes.
|
// remove interfaces and routes.
|
||||||
// This prevents from any assumptions that could be made from
|
// This prevents from any assumptions that could be made from
|
||||||
// virtcontainers, in particular that the VM has not been started
|
// virtcontainers, in particular that the VM has not been started
|
||||||
// before it starts to scan the current network.
|
// before it starts to scan the current network.
|
||||||
if s.factory != nil {
|
if s.factory == nil {
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the network
|
// Add the network
|
||||||
if err := s.network.add(s); err != nil {
|
if err := s.network.add(s); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Store the network
|
// Store the network
|
||||||
return s.storage.storeSandboxNetwork(s.id, s.networkNS)
|
return s.storage.storeSandboxNetwork(s.id, s.networkNS)
|
||||||
@ -1117,8 +1120,6 @@ func (s *Sandbox) startVM() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// FIXME: factory vm needs network hotplug to add Nics.
|
|
||||||
s.networkNS.NetNsPath = ""
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user