Skip to content

Commit 80a351a

Browse files
authored
Merge pull request #720 from flatcar/kai/default-confext
kola: Support default confext for /etc
2 parents 9f15ce2 + 7df6750 commit 80a351a

3 files changed

Lines changed: 31 additions & 12 deletions

File tree

‎kola/tests/misc/state.go‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,37 @@ func OverlayCleanup(c cluster.TestCluster) {
6969
// systemd-tmpfiles to cause any recreation at boot: This was observed with C, L, and d entries
7070
// (file or tree copy, symlink setup, directory creation) and thus they are dropped during image
7171
// build as workaround.
72-
overlayCheck := `sudo unshare -m bash -c 'umount /etc || { echo "Could not unmount /etc"; exit 1; }; if test -e "/etc/hosts" || test -e "/etc/security" || test -e "/etc/profile.d" || test -e "/etc/shells" || test -e "/etc/os-release" ; then echo "Unexpected overlay copy in /etc %s: $_" ; exit 1; fi'`
72+
overlayCheck := `sudo unshare -m bash -c 'umount -l /etc || { echo "Could not unmount /etc"; exit 1; }; if test -e "/etc/hosts" || test -e "/etc/security" || test -e "/etc/profile.d" || test -e "/etc/shells" || test -e "/etc/os-release" ; then echo "Unexpected overlay copy in /etc %s: $_" ; exit 1; fi'`
7373
_ = c.MustSSH(m, fmt.Sprintf(overlayCheck, "on initial boot"))
7474

7575
// Do some local modifications that are expected to be kept:
7676
// special cases are recreating a directory but empty, deleting a file, deleting a directory,
7777
// and recreating a directory with same contents plus a new file.
7878
// /etc/sssd should have the same permissions but the only difference is that the overlay
79-
// will add the overlay.opaque xattr, /etc/samba is an empty directory in case of samba <= 4.15,
80-
// but the test would also be valid if it had contents, /etc/bash/bashrc must exist for the test
79+
// will add the overlay.opaque xattr, /etc/wireguard is a directory that must exist in the lowerdir
80+
// but it's ok to delete it as nothing uses/recreates it, /etc/bash/bashrc must exist for the test
8181
// to work and the contents should get frozen and not touched by the cleanup because here we
8282
// recreate the folder (and add a new file in it) which means that the lowerdir folder isn't used
8383
// and deleting equal contents would not result in it being available.
8484
// All these files should not be part of the tmpfiles rules for the test to work.
85-
_ = c.MustSSH(m, `sudo rm -r /etc/sssd && sudo mkdir /etc/sssd && sudo chmod 700 /etc/sssd && sudo rm /etc/kexec.conf && sudo rm -rf /etc/samba && sudo rm -r /etc/bash && sudo cp -a /usr/share/flatcar/etc/bash /etc/bash && sudo touch /etc/bash/hello`)
85+
// NOTE: When this test fails due to package updates not shipping these files/directories under /etc
86+
// then you should fix the test by finding a similar file/directory to be used.
87+
_ = c.MustSSH(m, `sudo rm -r /etc/sssd && sudo mkdir /etc/sssd && sudo chmod 700 /etc/sssd && sudo rm /etc/kexec.conf && sudo rm -r /etc/wireguard && sudo rm -r /etc/bash && sudo cp -a /usr/share/flatcar/etc/bash /etc/bash && sudo touch /etc/bash/hello`)
8688

8789
// Test that /etc/resolv.conf will be recreated when removed
8890
_ = c.MustSSH(m, `sudo rm /etc/resolv.conf`)
8991

9092
// The migration path for old machines with a full /etc and the cleanup of unwanted duplicates/
9193
// upcopies can be tested the same way by copying duplicates to /etc and then rebooting to
9294
// check that they get cleaned up.
93-
_ = c.MustSSH(m, `sudo unshare -m bash -c 'umount /etc && cp -a /usr/share/flatcar/etc/{hosts,shells,os-release} /etc/ && mkdir /etc/security /etc/profile.d'`)
95+
_ = c.MustSSH(m, `sudo unshare -m bash -c 'umount -l /etc && cp -a /usr/share/flatcar/etc/{hosts,shells,os-release} /etc/ && mkdir /etc/security /etc/profile.d'`)
9496
if err := m.Reboot(); err != nil {
9597
c.Fatalf("could not reboot: %v", err)
9698
}
9799

98100
_ = c.MustSSH(m, fmt.Sprintf(overlayCheck, "after reboot"))
99-
_ = c.MustSSH(m, `if sudo test -e /etc/sssd/sssd.conf || test -e /etc/kexec.conf || test -e /etc/samba || test ! -e /etc/bash/hello || test ! -e /etc/bash/bashrc ; then echo "Deletion or modification lost: $_" ; exit 1; fi`)
100-
_ = c.MustSSH(m, `if test ! -e /etc/resolv.conf ; then echo "Files with tmpfile rule not recreated: $_" ; exit 1; fi && if ! sudo unshare -m bash -c 'umount /etc && test ! -e /etc/resolv.conf'; then echo "File with tmpfile rule exists as upcopy: $_"; exit 1; fi`)
101+
_ = c.MustSSH(m, `if sudo test -e /etc/sssd/sssd.conf || test -e /etc/kexec.conf || test -e /etc/wireguard || test ! -e /etc/bash/hello || test ! -e /etc/bash/bashrc ; then echo "Deletion or modification lost: $_" ; exit 1; fi`)
102+
_ = c.MustSSH(m, `if test ! -e /etc/resolv.conf ; then echo "Files with tmpfile rule not recreated: $_" ; exit 1; fi && if ! sudo unshare -m bash -c 'umount -l /etc && test ! -e /etc/resolv.conf'; then echo "File with tmpfile rule exists as upcopy: $_"; exit 1; fi`)
101103
}
102104

103105
// Check the OS reset logic with flatcar-reset to be able to

‎kola/tests/sysext/sysext.go‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ if [[ "${oem_test_type}" != 'raw' ]]; then
125125
fi
126126
127127
oem_test_path=$(jq --raw-output '.path' <<<"${list_oem_test}")
128-
if [[ "${oem_test_path}" != '/etc/extensions/oem-test.raw' ]]; then
129-
echo "oem test image path should be '/etc/extensions/oem-test.raw', is '${oem_test_path}'"
128+
oem_test_real_path=$(readlink -f /etc/extensions/oem-test.raw)
129+
if [[ "${oem_test_path}" != "${oem_test_real_path}" ]] && [[ "${oem_test_path}" != '/etc/extensions/oem-test.raw' ]]; then
130+
echo "oem test image path should be '${oem_test_real_path}' or '/etc/extensions/oem-test.raw', is '${oem_test_path}'"
130131
exit 1
131132
fi
132133
@@ -239,6 +240,14 @@ func init() {
239240
inline: |
240241
sysext works`),
241242
})
243+
register.Register(&register.Test{
244+
Name: "confext.skiprefresh",
245+
Run: checkConfextSkipRefresh,
246+
ClusterSize: 1,
247+
Distros: []string{"cl"},
248+
// This test is normally not related to the cloud environment
249+
Platforms: []string{"qemu", "qemu-unpriv"},
250+
MinVersion: semver.Version{Major: 4548}})
242251
register.Register(&register.Test{
243252
Name: "sysext.custom-docker.torcx",
244253
Run: checkSysextCustomDocker,
@@ -324,6 +333,12 @@ func checkSysextSimple(c cluster.TestCluster, oemMountpoint string) {
324333
checkHelper(c, oemMountpoint)
325334
}
326335

336+
func checkConfextSkipRefresh(c cluster.TestCluster) {
337+
// This test uses no extra extension images
338+
_ = c.MustSSH(c.Machines()[0], `if sudo journalctl -u systemd-confext -b0 | grep "Merged extensions into"; then echo "Unexpected confext merge, expected skip" ; exit 1 ; fi`)
339+
_ = c.MustSSH(c.Machines()[0], `if ! findmnt -O rw --target /etc >/dev/null; then echo "Missing or wrong /etc mount, expected rw"; exit 1; fi`)
340+
}
341+
327342
func checkSysextCustomDocker(c cluster.TestCluster) {
328343
arch := strings.SplitN(kola.QEMUOptions.Board, "-", 2)[0]
329344
if arch == "arm64" {
@@ -341,13 +356,14 @@ func checkSysextCustomDocker(c cluster.TestCluster) {
341356
// Flatcar has no mksquashfs and btrfs is missing a bugfix but at least ext4 works
342357
// The first test is for a fixed Docker version, which with the time will get old and older but is still expected to work because users may also "freeze" their Docker version this way
343358
_ = c.MustSSH(c.Machines()[0], fmt.Sprintf(`ARCH=%[1]s ONLY_DOCKER=1 FORMAT=ext4 sysext-bakery/create_docker_sysext.sh 20.10.21 docker && ARCH=%[1]s ONLY_CONTAINERD=1 FORMAT=ext4 sysext-bakery/create_docker_sysext.sh 20.10.21 containerd && sudo mv docker.raw containerd.raw /etc/extensions/`, arch))
344-
_ = c.MustSSH(c.Machines()[0], `sudo systemctl restart systemd-sysext`)
359+
// Explicit daemon-reload and docker start because the old bake.sh does not set EXTENSION_RELOAD_MANAGER=1
360+
_ = c.MustSSH(c.Machines()[0], `sudo systemctl restart systemd-sysext && sudo systemctl daemon-reload`)
345361
// We should now be able to use Docker
346362
_ = c.MustSSH(c.Machines()[0], cmdWorking)
347363
// The next test is with a recent Docker version, here the one from the Flatcar image to couple it to something that doesn't change under our feet
348364
version := string(c.MustSSH(c.Machines()[0], `bzcat /usr/share/licenses/licenses.json.bz2 | grep -m 1 -o 'app-\(containers\|emulation\)/docker-[0-9][^:]*' | cut -d - -f 3`))
349365
_ = c.MustSSH(c.Machines()[0], fmt.Sprintf(`ONLY_DOCKER=1 FORMAT=ext4 ARCH=%[2]s sysext-bakery/create_docker_sysext.sh %[1]s docker && ONLY_CONTAINERD=1 FORMAT=ext4 ARCH=%[2]s sysext-bakery/create_docker_sysext.sh %[1]s containerd && sudo mv docker.raw containerd.raw /etc/extensions/`, version, arch))
350-
_ = c.MustSSH(c.Machines()[0], `sudo systemctl restart systemd-sysext && sudo systemctl restart docker containerd`)
366+
_ = c.MustSSH(c.Machines()[0], `sudo systemctl restart systemd-sysext && sudo systemctl daemon-reload && sudo systemctl restart docker containerd`)
351367
// We should now still be able to use Docker
352368
_ = c.MustSSH(c.Machines()[0], cmdWorking)
353369
}

‎kola/tests/update/update.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ func sysextBootLogic(c cluster.TestCluster, oemMountpoint string) {
548548
// a) stored on the rootfs and will stay there and the new one is is moved to the OEM partition
549549
// b) stored on the OEM partition and gets moved to the rootfs and the new one is moved to the OEM partition
550550
_ = c.MustSSH(noIgnition, fmt.Sprintf(`set -euxo pipefail
551-
sudo systemctl mask --now systemd-sysext ensure-sysext
551+
sudo systemctl mask --now ensure-sysext || true # Old releases
552+
sudo systemctl mask --now systemd-sysext
552553
sudo mkdir -p /etc/flatcar/sysext /etc/flatcar/oem-sysext %[2]s/sysext /etc/extensions
553554
echo ID=test | sudo tee %[2]s/oem-release
554555
echo myext | sudo tee /etc/flatcar/enabled-sysext.conf

0 commit comments

Comments
 (0)