Skip to content

Commit

Permalink
container: do not try to join networkNS if using the node namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
  • Loading branch information
giuseppe committed May 31, 2018
1 parent 8f234d9 commit ed9c68b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -1067,15 +1067,22 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
}
}

netNsPath := sb.NetNsPath()
if netNsPath == "" {
// The sandbox does not have a permanent namespace,
// it's on the host one.
netNsPath = fmt.Sprintf("/proc/%d/ns/net", podInfraState.Pid)
}
// If the sandbox is configured to run in the host network, do not create a new network namespace
if sb.HostNetwork() {
if err := specgen.RemoveLinuxNamespace(string(rspec.NetworkNamespace)); err != nil {
return nil, err
}
} else {
netNsPath := sb.NetNsPath()
if netNsPath == "" {
// The sandbox does not have a permanent namespace,
// it's on the host one.
netNsPath = fmt.Sprintf("/proc/%d/ns/net", podInfraState.Pid)
}

if err := specgen.AddOrReplaceLinuxNamespace(string(rspec.NetworkNamespace), netNsPath); err != nil {
return nil, err
if err := specgen.AddOrReplaceLinuxNamespace(string(rspec.NetworkNamespace), netNsPath); err != nil {
return nil, err
}
}

imageSpec := containerConfig.GetImage()
Expand Down

0 comments on commit ed9c68b

Please sign in to comment.