Skip to content

Commit

Permalink
fix: podmannet test failing on Ubuntu 22.04LTS
Browse files Browse the repository at this point in the history
Signed-off-by: thediveo <[email protected]>
  • Loading branch information
thediveo committed Jan 18, 2024
1 parent 6aacc31 commit 58049ea
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
13 changes: 13 additions & 0 deletions decorator/podmannet/_test/pind/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,17 @@ RUN dnf -y install \
dnf clean all && \
rm -rf /var/cache /var/log/dnf* /var/log/yum.* && \
systemctl enable podman.socket
RUN echo $'[containers]\n\
netns="host"\n\
userns="host"\n\
ipcns="host"\n\
utsns="host"\n\
cgroupns="host"\n\
cgroups="disabled"\n\
log_driver = "k8s-file"\n\
[engine]\n\
cgroup_manager = "cgroupfs"\n\
events_logger="file"\n\
runtime="crun"\n\
' > /etc/containers/containers.conf
CMD [ "/usr/sbin/init" ]
35 changes: 19 additions & 16 deletions decorator/podmannet/podmannet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import (
"github.com/ory/dockertest/v3"
"github.com/ory/dockertest/v3/docker"
"github.com/siemens/ghostwire/v2/internal/discover"
"github.com/siemens/ghostwire/v2/network"
"github.com/siemens/turtlefinder"
"github.com/thediveo/lxkns/model"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gleak"
. "github.com/thediveo/fdooze"
"github.com/thediveo/lxkns/model"
. "github.com/thediveo/success"
)

Expand All @@ -29,6 +30,9 @@ const (
pindName = "ghostwire-pind"
pindImageName = "siemens/ghostwire-pind"

nifDiscoveryTimeout = 5 * time.Second
nifDiscoveryPolling = 250 * time.Millisecond

goroutinesUnwindTimeout = 2 * time.Second
goroutinesUnwindPolling = 250 * time.Millisecond
)
Expand Down Expand Up @@ -89,9 +93,9 @@ var _ = Describe("turtle finder", Ordered, Serial, func() {
Repository: pindImageName,
Privileged: true,
Mounts: []string{
"/var", // well, this actually is an unnamed volume
"/var/lib/containers", // well, this actually is an unnamed volume
},
Tty: true,
Tty: false,
}, func(hc *docker.HostConfig) {
hc.Init = false
hc.Tmpfs = map[string]string{
Expand Down Expand Up @@ -135,7 +139,11 @@ var _ = Describe("turtle finder", Ordered, Serial, func() {

By("running a canary container connected to the default 'podman' network")
Expect(pindCntr.Exec([]string{
"podman", "run", "-d", "-it", "--rm", "--name", "canary", "busybox",
"podman", "run", "-d", "--rm",
"--name", "canary",
"--net", "podman", /* WHAT?? otherwise doesn't connect the container??? */
"busybox",
"/bin/sh", "-c", "while true; do sleep 1; done",
}, dockertest.ExecOptions{
StdOut: GinkgoWriter,
StdErr: GinkgoWriter,
Expand Down Expand Up @@ -169,25 +177,20 @@ var _ = Describe("turtle finder", Ordered, Serial, func() {
defer cizer.Close()

By("running a full Ghostwire discovery that should pick up the podman networks")
allnetns, lxknsdisco := discover.Discover(ctx, cizer, nil)
Expect(lxknsdisco.Processes).To(HaveKey(model.PIDType(pindCntr.Container.State.Pid)))
pindNetnsID := lxknsdisco.Processes[model.PIDType(pindCntr.Container.State.Pid)].
Namespaces[model.NetNS].ID()
Expect(pindNetnsID).NotTo(BeZero())
Expect(allnetns).To(HaveKey(pindNetnsID))
pindNetns := allnetns[pindNetnsID]
// We expect the following network interfaces to be present inside our
// podman-in-docker container:
// - eth0 ... a.k.a. the "mcwielahm" network
// - podman0 ... a.k.a. the "podman" network
Expect(pindNetns.Nifs).To(ContainElements(
Eventually(ctx, func() map[int]network.Interface {
allnetns, lxknsdisco := discover.Discover(ctx, cizer, nil)
pindNetnsID := lxknsdisco.Processes[model.PIDType(pindCntr.Container.State.Pid)].
Namespaces[model.NetNS].ID()
return allnetns[pindNetnsID].Nifs
}).Within(nifDiscoveryPolling).ProbeEvery(nifDiscoveryPolling).Should(ContainElements(
HaveField("Nif()", And(
HaveField("Name", "eth0"),
HaveField("Alias", "mcwielahm"))),
HaveField("Nif()", And(
HaveField("Name", "podman0"),
HaveField("Alias", "podman"))),
))

})

})

0 comments on commit 58049ea

Please sign in to comment.