Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
virtcontainers: Don't handle the network in case of a factory
Browse files Browse the repository at this point in the history
If the sandbox has been initialized with a factory, this means the
caller should be in charge of adding any network to the VM, and
virtcontainers library cannot make any assumptions about adding
the default underlying network.

Signed-off-by: Sebastien Boeuf <[email protected]>
  • Loading branch information
Sebastien Boeuf committed Aug 24, 2018
1 parent 9c6ed93 commit 97d280e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,16 @@ func (s *Sandbox) createNetwork() error {
span, _ := s.trace("createNetwork")
defer span.Finish()

// In case there is a factory, the network should be handled
// through some calls at the API level, in order to add or
// remove interfaces and routes.
// This prevents from any assumptions that could be made from
// virtcontainers, in particular that the VM has not been started
// before it starts to scan the current network.
if s.factory != nil {
return nil
}

// Add the network
if err := s.network.add(s); err != nil {
return err
Expand All @@ -986,6 +996,13 @@ func (s *Sandbox) removeNetwork() error {
span, _ := s.trace("removeNetwork")
defer span.Finish()

// In case there is a factory, the network has been handled through
// some API calls to hotplug some interfaces and routes. This means
// the removal of the network should follow the same logic.
if s.factory != nil {
return nil
}

return s.network.remove(s)
}

Expand Down

0 comments on commit 97d280e

Please sign in to comment.