Skip to content

Commit d7e70c7

Browse files
committed
CI: set and verify DESIRED_NETWORK (netavark, cni)
We have CI tests running in netavark mode when CNI is desired. Add a new .cirrus.yml envariable, CI_DESIRED_NETWORK, which we then force-check in e2e and system tests. Simple copy/paste of #14912 (the RUNTIME check) with manual s/RUNTIME/NETWORK/ and other minor changes. Signed-off-by: Ed Santiago <[email protected]>
1 parent 774e950 commit d7e70c7

File tree

5 files changed

+63
-19
lines changed

5 files changed

+63
-19
lines changed

.cirrus.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,19 @@ build_task:
103103
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
104104
# ID for re-use of build output
105105
CI_DESIRED_RUNTIME: crun
106+
CI_DESIRED_NETWORK: netavark
106107
- env: &priorfedora_envvars
107108
DISTRO_NV: ${PRIOR_FEDORA_NAME}
108109
VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME}
109110
CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN}
110111
CI_DESIRED_RUNTIME: crun
112+
CI_DESIRED_NETWORK: cni
111113
#- env: &ubuntu_envvars
112114
# DISTRO_NV: ${UBUNTU_NAME}
113115
# VM_IMAGE_NAME: ${UBUNTU_CACHE_IMAGE_NAME}
114116
# CTR_FQIN: ${UBUNTU_CONTAINER_FQIN}
115117
# CI_DESIRED_RUNTIME: runc
118+
# CI_DESIRED_NETWORK: whatever
116119
env:
117120
TEST_FLAVOR: build
118121
# NOTE: The default way Cirrus-CI clones is *NOT* compatible with
@@ -192,6 +195,7 @@ build_aarch64_task:
192195
VM_IMAGE_NAME: ${FEDORA_AARCH64_AMI}
193196
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
194197
CI_DESIRED_RUNTIME: crun
198+
CI_DESIRED_NETWORK: netavark
195199
TEST_FLAVOR: build
196200
clone_script: *full_clone
197201
prebuild_script: *prebuild
@@ -591,11 +595,13 @@ container_integration_test_task:
591595
VM_IMAGE_NAME: ${FEDORA_CACHE_IMAGE_NAME}
592596
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
593597
CI_DESIRED_RUNTIME: crun
598+
CI_DESIRED_NETWORK: netavark
594599
- env:
595600
DISTRO_NV: ${PRIOR_FEDORA_NAME}
596601
VM_IMAGE_NAME: ${PRIOR_FEDORA_CACHE_IMAGE_NAME}
597602
CTR_FQIN: ${PRIOR_FEDORA_CONTAINER_FQIN}
598603
CI_DESIRED_RUNTIME: crun
604+
CI_DESIRED_NETWORK: cni
599605
gce_instance: *standardvm
600606
timeout_in: 90m
601607
env:
@@ -650,6 +656,7 @@ podman_machine_task:
650656
PRIV_NAME: "rootless" # intended use-case
651657
DISTRO_NV: "${FEDORA_NAME}"
652658
VM_IMAGE_NAME: "${FEDORA_AMI}"
659+
CI_DESIRED_NETWORK: netavark
653660
clone_script: *get_gosrc
654661
setup_script: *setup
655662
main_script: *main
@@ -675,6 +682,7 @@ podman_machine_aarch64_task:
675682
PRIV_NAME: "rootless" # intended use-case
676683
DISTRO_NV: "${FEDORA_AARCH64_NAME}"
677684
VM_IMAGE_NAME: "${FEDORA_AARCH64_AMI}"
685+
CI_DESIRED_NETWORK: netavark
678686
clone_script: *get_gosrc_aarch64
679687
setup_script: *setup
680688
main_script: *main
@@ -760,6 +768,7 @@ rootless_remote_system_test_task:
760768
VM_IMAGE_NAME: ${FEDORA_CACHE_IMAGE_NAME}
761769
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
762770
CI_DESIRED_RUNTIME: crun
771+
CI_DESIRED_NETWORK: netavark
763772
<<: *local_system_test_task
764773
alias: rootless_remote_system_test
765774
depends_on:
@@ -822,6 +831,7 @@ buildah_bud_test_task:
822831
# Not used here, is used in other tasks
823832
VM_IMAGE_NAME: ${FEDORA_CACHE_IMAGE_NAME}
824833
CTR_FQIN: ${FEDORA_CONTAINER_FQIN}
834+
CI_DESIRED_NETWORK: netavark
825835
matrix:
826836
- env:
827837
PODBIN_NAME: podman
@@ -874,10 +884,13 @@ upgrade_test_task:
874884
matrix:
875885
- env:
876886
PODMAN_UPGRADE_FROM: v2.1.1
887+
CI_DESIRED_NETWORK: cni
877888
- env:
878889
PODMAN_UPGRADE_FROM: v3.1.2
890+
CI_DESIRED_NETWORK: cni
879891
- env:
880892
PODMAN_UPGRADE_FROM: v3.4.4
893+
CI_DESIRED_NETWORK: cni
881894
gce_instance: *standardvm
882895
env:
883896
TEST_FLAVOR: upgrade_test

contrib/cirrus/lib.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ use_cni() {
214214
msg "Force-removing netavark and aardvark-dns"
215215
# Other packages depend on nv/av, but we're testing with podman
216216
# binaries built from source, so it's safe to ignore these deps.
217+
#
218+
# FIXME FIXME FIXME: if/when we bring back Ubuntu (or use Debian),
219+
# someone will have to conditionalize these rpm/dnf commands
217220
rpm -e --nodeps netavark aardvark-dns
218221
msg "Installing default CNI configuration"
219222
dnf install -y $PACKAGE_DOWNLOAD_DIR/podman-plugins*
@@ -236,9 +239,9 @@ use_netavark() {
236239
export NETWORK_BACKEND=netavark # needed for install_test_configs()
237240
msg "Removing any/all CNI configuration"
238241
rm -rvf /etc/cni/net.d/*
239-
# N/B: The netavark/aardvark-dns packages are still installed and
240-
# available. This is on purpose, since CI needs to verify the
241-
# selection mechanisms are functional when both are available.
242+
# N/B: The CNI packages are still installed and available. This is
243+
# on purpose, since CI needs to verify the selection mechanisms are
244+
# functional when both are available.
242245
}
243246

244247
# Remove all files provided by the distro version of podman.

contrib/cirrus/setup_environment.sh

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,26 +125,19 @@ case "$OS_RELEASE_ID" in
125125
msg "Enabling container_manage_cgroup"
126126
setsebool container_manage_cgroup true
127127
fi
128-
129-
# For the latest Fedora CI VM images, netavark/aardvark is the
130-
# intended networking stack for podman. All previous VM images
131-
# should use CNI networking. Upgrading from one to the other is
132-
# not supported at this time. The only exception in CI is
133-
# the "upgrade tests" which must always use CNI.
134-
#
135-
# OS_RELEASE_VER is defined by automation-library
136-
# shellcheck disable=SC2154
137-
if [[ "$DISTRO_NV" != "$PRIOR_FEDORA_NAME" ]] && \
138-
[[ "$TEST_FLAVOR" != "upgrade_test" ]];
139-
then
140-
use_netavark
141-
else # Fedora N-1 or upgrade testing.
142-
use_cni
143-
fi
144128
;;
145129
*) die_unknown OS_RELEASE_ID
146130
esac
147131

132+
# Networking: force CNI or Netavark as requested in .cirrus.yml
133+
# (this variable is mandatory).
134+
# shellcheck disable=SC2154
135+
case "$CI_DESIRED_NETWORK" in
136+
netavark) use_netavark ;;
137+
cni) use_cni ;;
138+
*) die_unknown CI_DESIRED_NETWORK ;;
139+
esac
140+
148141
# Required to be defined by caller: The environment where primary testing happens
149142
# shellcheck disable=SC2154
150143
case "$TEST_ENVIRON" in
@@ -196,6 +189,7 @@ esac
196189
# Required to be defined by caller: Are we testing as root or a regular user
197190
case "$PRIV_NAME" in
198191
root)
192+
# shellcheck disable=SC2154
199193
if [[ "$TEST_FLAVOR" = "sys" || "$TEST_FLAVOR" = "apiv2" ]]; then
200194
# Used in local image-scp testing
201195
setup_rootless
@@ -212,6 +206,7 @@ case "$PRIV_NAME" in
212206
*) die_unknown PRIV_NAME
213207
esac
214208

209+
# shellcheck disable=SC2154
215210
if [[ -n "$ROOTLESS_USER" ]]; then
216211
echo "ROOTLESS_USER=$ROOTLESS_USER" >> /etc/ci_environment
217212
echo "ROOTLESS_UID=$ROOTLESS_UID" >> /etc/ci_environment

test/e2e/info_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,19 @@ var _ = Describe("Podman Info", func() {
166166
Expect(session).To(Exit(0))
167167
Expect(session.OutputToString()).To(Equal(want))
168168
})
169+
170+
It("Podman info: check desired network backend", func() {
171+
// defined in .cirrus.yml
172+
want := os.Getenv("CI_DESIRED_NETWORK")
173+
if want == "" {
174+
if os.Getenv("CIRRUS_CI") == "" {
175+
Skip("CI_DESIRED_NETWORK is not set--this is OK because we're not running under Cirrus")
176+
}
177+
Fail("CIRRUS_CI is set, but CI_DESIRED_NETWORK is not! See #16389")
178+
}
179+
session := podmanTest.Podman([]string{"info", "--format", "{{.Host.NetworkBackend}}"})
180+
session.WaitWithDefaultTimeout()
181+
Expect(session).To(Exit(0))
182+
Expect(session.OutputToString()).To(Equal(want))
183+
})
169184
})

test/system/005-info.bats

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,24 @@ host.slirp4netns.executable | $expr_path
7575
is "$output" "$CI_DESIRED_RUNTIME" "CI_DESIRED_RUNTIME (from .cirrus.yml)"
7676
}
7777

78+
@test "podman info - confirm desired network backend" {
79+
if [[ -z "$CI_DESIRED_NETWORK" ]]; then
80+
# When running in Cirrus, CI_DESIRED_NETWORK *must* be defined
81+
# in .cirrus.yml so we can double-check that all CI VMs are
82+
# using netavark or cni as desired.
83+
if [[ -n "$CIRRUS_CI" ]]; then
84+
die "CIRRUS_CI is set, but CI_DESIRED_NETWORK is not! See #16389"
85+
fi
86+
87+
# Not running under Cirrus (e.g., gating tests, or dev laptop).
88+
# Totally OK to skip this test.
89+
skip "CI_DESIRED_NETWORK is unset--OK, because we're not in Cirrus"
90+
fi
91+
92+
run_podman info --format '{{.Host.NetworkBackend}}'
93+
is "$output" "$CI_DESIRED_NETWORK" "CI_DESIRED_NETWORK (from .cirrus.yml)"
94+
}
95+
7896
# 2021-04-06 discussed in watercooler: RHEL must never use crun, even if
7997
# using cgroups v2.
8098
@test "podman info - RHEL8 must use runc" {

0 commit comments

Comments
 (0)