mirror of
https://github.com/containers/podman.git
synced 2025-08-06 03:19:52 +08:00
pkg/specgen: parse default network mode on server
When podman-remote is used we should not resolve the default network mode on the client. Defaults should be set on the server. In this case this is important because we have different defaults for root/rootless. So when the client is rootless and the server is root we must pick the root default. Note that this already worked when --network was set since we did not parsed the flag in this case. To reproduce you need --network=default. Also removed a unused function. [NO NEW TESTS NEEDED] I tested it manually but I am not sure how I can hook a test like this up in CI. The client would need to run as rootless and the server as root or the other way around. Fixes #14368 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -236,10 +236,12 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod.
|
||||
toReturn = append(toReturn, libpod.WithCgroupsMode(s.CgroupsMode))
|
||||
}
|
||||
|
||||
// Net
|
||||
// TODO validate CNINetworks, StaticIP, StaticIPv6 are only set if we
|
||||
// are in bridge mode.
|
||||
postConfigureNetNS := !s.UserNS.IsHost()
|
||||
// when we are rootless we default to slirp4netns
|
||||
if rootless.IsRootless() && (s.NetNS.IsPrivate() || s.NetNS.IsDefault()) {
|
||||
s.NetNS.NSMode = specgen.Slirp
|
||||
}
|
||||
|
||||
switch s.NetNS.NSMode {
|
||||
case specgen.FromPod:
|
||||
if pod == nil || infraCtr == nil {
|
||||
@ -262,9 +264,7 @@ func namespaceOptions(s *specgen.SpecGenerator, rt *libpod.Runtime, pod *libpod.
|
||||
val = fmt.Sprintf("slirp4netns:%s", s.NetNS.Value)
|
||||
}
|
||||
toReturn = append(toReturn, libpod.WithNetNS(portMappings, expose, postConfigureNetNS, val, nil))
|
||||
case specgen.Private:
|
||||
fallthrough
|
||||
case specgen.Bridge:
|
||||
case specgen.Bridge, specgen.Private, specgen.Default:
|
||||
portMappings, expose, err := createPortMappings(s, imageData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user