Skip to content

Commit

Permalink
Merge pull request #22219 from TomSweeneyRedHat/dev/tsweeney/v5.0_bui…
Browse files Browse the repository at this point in the history
…ldah_1.35.3

[v5.0] Bump Buildah to v1.35.3
  • Loading branch information
openshift-merge-bot[bot] authored Mar 31, 2024
2 parents 631cb95 + 2967eb9 commit 1ecd7d0
Show file tree
Hide file tree
Showing 27 changed files with 426 additions and 258 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/checkpoint-restore/checkpointctl v1.1.0
github.com/checkpoint-restore/go-criu/v7 v7.0.0
github.com/containernetworking/plugins v1.4.0
github.com/containers/buildah v1.35.1
github.com/containers/common v0.58.0
github.com/containers/buildah v1.35.3
github.com/containers/common v0.58.1
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/gvisor-tap-vsock v0.7.3
github.com/containers/image/v5 v5.30.0
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ github.com/containernetworking/cni v1.1.2 h1:wtRGZVv7olUHMOqouPpn3cXJWpJgM6+EUl3
github.com/containernetworking/cni v1.1.2/go.mod h1:sDpYKmGVENF3s6uvMvGgldDWeG8dMxakj/u+i9ht9vw=
github.com/containernetworking/plugins v1.4.0 h1:+w22VPYgk7nQHw7KT92lsRmuToHvb7wwSv9iTbXzzic=
github.com/containernetworking/plugins v1.4.0/go.mod h1:UYhcOyjefnrQvKvmmyEKsUA+M9Nfn7tqULPpH0Pkcj0=
github.com/containers/buildah v1.35.1 h1:m4TF6V8b06cS4jH9/t39PUsUIjzDQg/P14FLpwjr40Y=
github.com/containers/buildah v1.35.1/go.mod h1:vVSVUlTu8+99H5j43gBJscpkb/quZvdJg78+6X1HeTM=
github.com/containers/common v0.58.0 h1:iQuwMxDD4ubZ9s1tmgdsiaHxMU4TdVBpV6kctJc6Bk8=
github.com/containers/common v0.58.0/go.mod h1:l3vMqanJGj7tZ3W/i76gEJ128VXgFUO1tLaohJXPvdk=
github.com/containers/buildah v1.35.3 h1:Dn8Krwm2PemBNNOMwp7uiMK2e5cW2ZjTdLRzKM789pc=
github.com/containers/buildah v1.35.3/go.mod h1:kYi6vTHdbr1gnRo3B/RhTHsY2if/w398+/RvCxAXqkQ=
github.com/containers/common v0.58.1 h1:E1DN9Lr7kgMVQy7AXLv1CYQCiqnweklMiYWbf0KOnqY=
github.com/containers/common v0.58.1/go.mod h1:l3vMqanJGj7tZ3W/i76gEJ128VXgFUO1tLaohJXPvdk=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/gvisor-tap-vsock v0.7.3 h1:yORnf15sP+sLFhxLNLgmB5/lOhldn9dRMHx/tmYtSOQ=
Expand Down
2 changes: 2 additions & 0 deletions libpod/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"time"

"github.com/containers/common/libnetwork/pasta"
"github.com/containers/common/libnetwork/types"
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/secrets"
Expand Down Expand Up @@ -127,6 +128,7 @@ type Container struct {
restoreFromCheckpoint bool

slirp4netnsSubnet *net.IPNet
pastaResult *pasta.SetupResult
}

// ContainerState contains the current state of the container
Expand Down
28 changes: 11 additions & 17 deletions libpod/container_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,29 +301,23 @@ func (c *Container) handleRestartPolicy(ctx context.Context) (_ bool, retErr err
}
}()

// Now this is a bit of a mess, normally we try to reuse the netns but if a userns
// is used this is not possible as it must be owned by the userns which is created
// by the oci runtime. Thus we need to teardown the netns so that the runtime
// creates the users+netns and then we setup in completeNetworkSetup() again.
if c.config.PostConfigureNetNS {
if err := c.cleanupNetwork(); err != nil {
return false, err
}
// Always teardown the network, trying to reuse the netns has caused
// a significant amount of bugs in this code here. It also never worked
// for containers with user namespaces. So once and for all simplify this
// by never reusing the netns. Originally this was done to have a faster
// restart of containers but with netavark now we are much faster so it
// shouldn't be that noticeable in practice. It also makes more sense to
// reconfigure the netns as it is likely that the container exited due
// some broken network state in which case reusing would just cause more
// harm than good.
if err := c.cleanupNetwork(); err != nil {
return false, err
}

if err := c.prepare(); err != nil {
return false, err
}

// only do this if the container is not in a userns, if we are the cleanupNetwork()
// was called above and a proper network setup is needed which is part of the init() below.
if !c.config.PostConfigureNetNS {
// set up slirp4netns again because slirp4netns will die when conmon exits
if err := c.setupRootlessNetwork(); err != nil {
return false, err
}
}

if c.state.State == define.ContainerStateStopped {
// Reinitialize the container if we need to
if err := c.reinit(ctx, true); err != nil {
Expand Down
32 changes: 21 additions & 11 deletions libpod/container_internal_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"io"
"math"
"net"
"os"
"os/user"
"path"
Expand Down Expand Up @@ -2116,8 +2117,8 @@ func (c *Container) addResolvConf() error {
// first add the nameservers from the networks status
nameservers = networkNameServers

// slirp4netns has a built in DNS forwarder.
nameservers = c.addSlirp4netnsDNS(nameservers)
// pasta and slirp4netns have a built in DNS forwarder.
nameservers = c.addSpecialDNS(nameservers)
}

// Set DNS search domains
Expand Down Expand Up @@ -2167,6 +2168,10 @@ func (c *Container) checkForIPv6(netStatus map[string]types.StatusBlock) bool {
}
}

if c.pastaResult != nil {
return c.pastaResult.IPv6
}

return c.isSlirp4netnsIPv6()
}

Expand Down Expand Up @@ -2225,11 +2230,10 @@ func (c *Container) getHostsEntries() (etchosts.HostEntries, error) {
case c.config.NetMode.IsBridge():
entries = etchosts.GetNetworkHostEntries(c.state.NetworkStatus, names...)
case c.config.NetMode.IsPasta():
ip, err := getPastaIP(c.state)
if err != nil {
return nil, err
// this should never be the case but check just to be sure and not panic
if len(c.pastaResult.IPAddresses) > 0 {
entries = etchosts.HostEntries{{IP: c.pastaResult.IPAddresses[0].String(), Names: names}}
}
entries = etchosts.HostEntries{{IP: ip.String(), Names: names}}
case c.config.NetMode.IsSlirp4netns():
ip, err := getSlirp4netnsIP(c.slirp4netnsSubnet)
if err != nil {
Expand Down Expand Up @@ -2276,12 +2280,18 @@ func (c *Container) addHosts() error {
return err
}

var exclude []net.IP
if c.pastaResult != nil {
exclude = c.pastaResult.IPAddresses
}

return etchosts.New(&etchosts.Params{
BaseFile: baseHostFile,
ExtraHosts: c.config.HostAdd,
ContainerIPs: containerIPsEntries,
HostContainersInternalIP: etchosts.GetHostContainersInternalIP(c.runtime.config, c.state.NetworkStatus, c.runtime.network),
TargetFile: targetFile,
BaseFile: baseHostFile,
ExtraHosts: c.config.HostAdd,
ContainerIPs: containerIPsEntries,
HostContainersInternalIP: etchosts.GetHostContainersInternalIPExcluding(
c.runtime.config, c.state.NetworkStatus, c.runtime.network, exclude),
TargetFile: targetFile,
})
}

Expand Down
2 changes: 1 addition & 1 deletion libpod/container_internal_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func (c *Container) setCgroupsPath(g *generate.Generator) error {
return nil
}

func (c *Container) addSlirp4netnsDNS(nameservers []string) []string {
func (c *Container) addSpecialDNS(nameservers []string) []string {
return nameservers
}

Expand Down
28 changes: 6 additions & 22 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,27 +413,6 @@ func (c *Container) getOCICgroupPath() (string, error) {
}
}

// If the container is rootless, set up the slirp4netns network
func (c *Container) setupRootlessNetwork() error {
// set up slirp4netns again because slirp4netns will die when conmon exits
if c.config.NetMode.IsSlirp4netns() {
err := c.runtime.setupSlirp4netns(c, c.state.NetNS)
if err != nil {
return err
}
}

// set up rootlesskit port forwarder again since it dies when conmon exits
// we use rootlesskit port forwarder only as rootless and when bridge network is used
if rootless.IsRootless() && c.config.NetMode.IsBridge() && len(c.config.PortMappings) > 0 {
err := c.runtime.setupRootlessPortMappingViaRLK(c, c.state.NetNS, c.state.NetworkStatus)
if err != nil {
return err
}
}
return nil
}

func openDirectory(path string) (fd int, err error) {
return unix.Open(path, unix.O_RDONLY|unix.O_PATH, 0)
}
Expand Down Expand Up @@ -616,7 +595,12 @@ func (c *Container) setCgroupsPath(g *generate.Generator) error {
return nil
}

func (c *Container) addSlirp4netnsDNS(nameservers []string) []string {
// addSpecialDNS adds special dns servers for slirp4netns and pasta
func (c *Container) addSpecialDNS(nameservers []string) []string {
if c.pastaResult != nil {
nameservers = append(nameservers, c.pastaResult.DNSForwardIPs...)
}

// slirp4netns has a built in DNS forwarder.
if c.config.NetMode.IsSlirp4netns() {
slirp4netnsDNS, err := slirp4netns.GetDNS(c.slirp4netnsSubnet)
Expand Down
4 changes: 0 additions & 4 deletions libpod/networking_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,3 @@ func (c *Container) reloadRootlessRLKPortMapping() error {
func (c *Container) setupRootlessNetwork() error {
return nil
}

func getPastaIP(state *ContainerState) (net.IP, error) {
return nil, fmt.Errorf("pasta networking is Linux only")
}
11 changes: 0 additions & 11 deletions libpod/networking_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/containernetworking/plugins/pkg/ns"
"github.com/containers/common/libnetwork/types"
netUtil "github.com/containers/common/libnetwork/util"
"github.com/containers/common/pkg/netns"
"github.com/containers/podman/v5/libpod/define"
"github.com/containers/podman/v5/pkg/rootless"
Expand Down Expand Up @@ -300,13 +299,3 @@ func (c *Container) inspectJoinedNetworkNS(networkns string) (q types.StatusBloc
})
return result, err
}

func getPastaIP(state *ContainerState) (net.IP, error) {
var ip string
err := ns.WithNetNSPath(state.NetNS, func(_ ns.NetNS) error {
// get the first ip in the netns
ip = netUtil.GetLocalIP()
return nil
})
return net.ParseIP(ip), err
}
7 changes: 6 additions & 1 deletion libpod/networking_pasta_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ package libpod
import "github.com/containers/common/libnetwork/pasta"

func (r *Runtime) setupPasta(ctr *Container, netns string) error {
return pasta.Setup(&pasta.SetupOptions{
res, err := pasta.Setup2(&pasta.SetupOptions{
Config: r.config,
Netns: netns,
Ports: ctr.convertPortMappings(),
ExtraOptions: ctr.config.NetworkOptions[pasta.BinaryName],
})
if err != nil {
return err
}
ctr.pastaResult = res
return nil
}
7 changes: 5 additions & 2 deletions test/system/505-networking-pasta.bats
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,12 @@ function pasta_test_do() {
@test "Local forwarder, IPv4" {
skip_if_no_ipv4 "IPv4 not routable on the host"

run_podman run --dns 198.51.100.1 \
--net=pasta:--dns-forward,198.51.100.1 $IMAGE nslookup 127.0.0.1 || :
# pasta is the default now so no need to set it
run_podman run --rm $IMAGE grep nameserver /etc/resolv.conf
assert "${lines[0]}" == "nameserver 169.254.0.1" "default dns forward server"

run_podman run --rm --net=pasta:--dns-forward,198.51.100.1 \
$IMAGE nslookup 127.0.0.1 || :
assert "$output" =~ "1.0.0.127.in-addr.arpa" "No answer from resolver"
}

Expand Down
9 changes: 9 additions & 0 deletions vendor/github.com/containers/buildah/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions vendor/github.com/containers/buildah/changelog.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/containers/buildah/define/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/github.com/containers/buildah/run.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1ecd7d0

Please sign in to comment.