diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 542b734f41d..ab4cef72458 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -33,7 +33,7 @@ jobs: strategy: matrix: arch: ${{fromJson(needs.detect.outputs.arch)}} - flavor: ['green', 'tumbleweed', 'blue'] + flavor: ['green', 'tumbleweed', 'blue', 'orange'] uses: ./.github/workflows/build_and_test.yaml with: arch: ${{ matrix.arch }} diff --git a/examples/orange/05_network.yaml b/examples/orange/05_network.yaml new file mode 100644 index 00000000000..9cb4104685b --- /dev/null +++ b/examples/orange/05_network.yaml @@ -0,0 +1,32 @@ +# Example network configuration for Ubuntu based systems +name: "Default network configuration" +stages: + initramfs: + - name: "Setup network" + files: + - path: /etc/netplan/elemental_setup.yaml + content: | + network: + version: 2 + renderer: networkd + ethernets: + lan0: + dhcp4: true + permissions: 0600 + owner: 0 + group: 0 + - path: /etc/ssh/sshd_config.d/root_login.conf + content: | + PermitRootLogin yes + permissions: 0600 + owner: 0 + group: 0 + - path: /etc/udev/rules.d/70-persistent-net.rules + content: | + SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="?*", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="?*", NAME="lan0" + permissions: 0600 + owner: 0 + group: 0 + commands: + - ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf + - netplan apply diff --git a/examples/orange/Dockerfile b/examples/orange/Dockerfile index 5dcd71179b8..285625843d2 100644 --- a/examples/orange/Dockerfile +++ b/examples/orange/Dockerfile @@ -4,7 +4,7 @@ ARG VERSION FROM ${TOOLKIT_REPO}:${VERSION} as TOOLKIT # OS base image of our choice -FROM ubuntu:23.04 as OS +FROM ubuntu:22.04 as OS ARG REPO ARG VERSION ENV VERSION=${VERSION} @@ -23,7 +23,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins shim-signed \ haveged \ systemd \ - systemd-resolved \ + systemd-sysv \ + systemd-timesyncd \ openssh-server \ openssh-client \ tzdata \ @@ -45,6 +46,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins iproute2 \ dbus-daemon \ patch \ + netplan.io \ xz-utils # Create non FHS paths @@ -60,14 +62,6 @@ RUN systemctl enable systemd-networkd.service && \ # Enable /tmp to be on tmpfs RUN cp /usr/share/systemd/tmp.mount /etc/systemd/system -# This is patches are fix upstream dracut, see https://github.com/dracutdevs/dracut/pull/2525 -ADD patches / - -RUN cd /usr/lib/dracut && \ - patch -p 1 -f -i /0001-fix-dmsquash-live-restore-compatibility-with-earlier.patch && \ - patch -p 1 -f -i /0001-fix-overlayfs-split-overlayfs-mount-in-two-steps.patch && \ - rm /*.patch - # Generate initrd with required elemental services RUN elemental --debug init -f @@ -78,6 +72,9 @@ RUN echo IMAGE_REPO=\"${REPO}\" >> /etc/os-release && \ echo TIMESTAMP="`date +'%Y%m%d%H%M%S'`" >> /etc/os-release RUN echo GRUB_ENTRY_NAME=\"Elemental\" >> /etc/os-release +# Adding specific network configuration based on netplan +ADD 05_network.yaml /system/oem/05_network.yaml + # Arrange bootloader binaries into /boot/efi/EFI/elemental # this way elemental installer can easily fetch them RUN mkdir -p /boot/efi/EFI/elemental && \ diff --git a/examples/orange/patches/0001-fix-dmsquash-live-restore-compatibility-with-earlier.patch b/examples/orange/patches/0001-fix-dmsquash-live-restore-compatibility-with-earlier.patch deleted file mode 100644 index 1f9908ec2cc..00000000000 --- a/examples/orange/patches/0001-fix-dmsquash-live-restore-compatibility-with-earlier.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0e780720efe6488c4e07af39926575ee12f40339 Mon Sep 17 00:00:00 2001 -From: Laszlo Gombos -Date: Fri, 24 Feb 2023 01:57:19 +0000 -Subject: [PATCH] fix(dmsquash-live): restore compatibility with earlier - releases - -Follow-up to 40dd5c90e0efcb9ebaa9abb42a38c7316e9706bd . ---- - modules.d/90dmsquash-live/dmsquash-live-root.sh | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh -index 62d1b5e7..a98e258c 100755 ---- a/modules.d/90dmsquash-live/dmsquash-live-root.sh -+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh -@@ -403,6 +403,10 @@ fi - - ROOTFLAGS="$(getarg rootflags)" - -+if [ "$overlayfs" = required ]; then -+ echo "rd.live.overlay.overlayfs=1" > /etc/cmdline.d/dmsquash-need-overlay.conf -+fi -+ - if [ -n "$overlayfs" ]; then - if [ -n "$FSIMG" ]; then - mkdir -m 0755 -p /run/rootfsbase --- -2.35.3 - diff --git a/examples/orange/patches/0001-fix-overlayfs-split-overlayfs-mount-in-two-steps.patch b/examples/orange/patches/0001-fix-overlayfs-split-overlayfs-mount-in-two-steps.patch deleted file mode 100644 index f943b05c367..00000000000 --- a/examples/orange/patches/0001-fix-overlayfs-split-overlayfs-mount-in-two-steps.patch +++ /dev/null @@ -1,91 +0,0 @@ -From bddffedae038ceca263a904e40513a6e92f1b558 Mon Sep 17 00:00:00 2001 -From: David Cassany -Date: Fri, 22 Sep 2023 16:28:48 +0200 -Subject: [PATCH] fix(overlayfs): split overlayfs mount in two steps - -This commit splits the creation of required overlayfs underlaying -directories and the actual overlayfs mount. This way it is still -possible to mount the overlayfs with the generated sysroot.mount that -dmsquash-live creates. - -The overlayfs tree is created in a pre-mount hook so it is executed -before sysroot.mount is started. Otherwise sysroot.mount starts and -fails before mount hooks are executed. - -Signed-off-by: David Cassany ---- - modules.d/90overlayfs/module-setup.sh | 1 + - modules.d/90overlayfs/mount-overlayfs.sh | 13 ------------- - modules.d/90overlayfs/prepare-overlayfs.sh | 21 +++++++++++++++++++++ - 3 files changed, 22 insertions(+), 13 deletions(-) - create mode 100755 modules.d/90overlayfs/prepare-overlayfs.sh - -diff --git a/modules.d/90overlayfs/module-setup.sh b/modules.d/90overlayfs/module-setup.sh -index 27aa7cfa..893e2dc3 100755 ---- a/modules.d/90overlayfs/module-setup.sh -+++ b/modules.d/90overlayfs/module-setup.sh -@@ -15,4 +15,5 @@ installkernel() { - - install() { - inst_hook mount 01 "$moddir/mount-overlayfs.sh" -+ inst_hook pre-mount 01 "$moddir/prepare-overlayfs.sh" - } -diff --git a/modules.d/90overlayfs/mount-overlayfs.sh b/modules.d/90overlayfs/mount-overlayfs.sh -index 7e2da1a8..e1d23fb4 100755 ---- a/modules.d/90overlayfs/mount-overlayfs.sh -+++ b/modules.d/90overlayfs/mount-overlayfs.sh -@@ -3,24 +3,11 @@ - type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh - - getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" --getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes" - getargbool 0 rd.live.overlay.readonly -d -y readonly_overlay && readonly_overlay="--readonly" || readonly_overlay="" - - ROOTFLAGS="$(getarg rootflags)" - - if [ -n "$overlayfs" ]; then -- if ! [ -e /run/rootfsbase ]; then -- mkdir -m 0755 -p /run/rootfsbase -- mount --bind "$NEWROOT" /run/rootfsbase -- fi -- -- mkdir -m 0755 -p /run/overlayfs -- mkdir -m 0755 -p /run/ovlwork -- if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then -- ovlfsdir=$(readlink /run/overlayfs) -- info "Resetting the OverlayFS overlay directory." -- rm -r -- "${ovlfsdir:?}"/* "${ovlfsdir:?}"/.* > /dev/null 2>&1 -- fi - if [ -n "$readonly_overlay" ] && [ -h /run/overlayfs-r ]; then - ovlfs=lowerdir=/run/overlayfs-r:/run/rootfsbase - else -diff --git a/modules.d/90overlayfs/prepare-overlayfs.sh b/modules.d/90overlayfs/prepare-overlayfs.sh -new file mode 100755 -index 00000000..87bcc196 ---- /dev/null -+++ b/modules.d/90overlayfs/prepare-overlayfs.sh -@@ -0,0 +1,21 @@ -+#!/bin/sh -+ -+type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh -+ -+getargbool 0 rd.live.overlay.overlayfs && overlayfs="yes" -+getargbool 0 rd.live.overlay.reset -d -y reset_overlay && reset_overlay="yes" -+ -+if [ -n "$overlayfs" ]; then -+ if ! [ -e /run/rootfsbase ]; then -+ mkdir -m 0755 -p /run/rootfsbase -+ mount --bind "$NEWROOT" /run/rootfsbase -+ fi -+ -+ mkdir -m 0755 -p /run/overlayfs -+ mkdir -m 0755 -p /run/ovlwork -+ if [ -n "$reset_overlay" ] && [ -h /run/overlayfs ]; then -+ ovlfsdir=$(readlink /run/overlayfs) -+ info "Resetting the OverlayFS overlay directory." -+ rm -r -- "${ovlfsdir:?}"/* "${ovlfsdir:?}"/.* > /dev/null 2>&1 -+ fi -+fi --- -2.35.3 - diff --git a/go.mod b/go.mod index a875a557d0a..31b08ca67ed 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/mudler/yip v1.4.0 github.com/onsi/ginkgo/v2 v2.9.3 github.com/onsi/gomega v1.27.6 - github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231031082920-8b1cf3f8c16f + github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231121104300-eb56c5436c4e github.com/sanity-io/litter v1.5.5 github.com/sirupsen/logrus v1.9.0 github.com/spf13/cobra v1.7.0 diff --git a/go.sum b/go.sum index 414967f3072..25d0b7ee250 100644 --- a/go.sum +++ b/go.sum @@ -410,8 +410,8 @@ github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y8 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231031082920-8b1cf3f8c16f h1:GUKwalxjMDhbxMmhhBFZ91jubBOxwYvu1q8sA+jk2Jg= -github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231031082920-8b1cf3f8c16f/go.mod h1:Ex+a/ng4u2BvcGQdQjTHI48h88bQ6k2a7q8rnvU0XbQ= +github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231121104300-eb56c5436c4e h1:1pWxPAbjDxLWadV1goUOVZBzUqDKkD8pqwE2Nbzpd30= +github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231121104300-eb56c5436c4e/go.mod h1:Ex+a/ng4u2BvcGQdQjTHI48h88bQ6k2a7q8rnvU0XbQ= github.com/rancher-sandbox/linuxkit v1.0.1 h1:LYKmv1XozmQGRV6Ilm88Fx/t54okVa8rx00wLJPZkBw= github.com/rancher-sandbox/linuxkit v1.0.1/go.mod h1:n6Fkjc5qoMeWrnLSA5oqUF8ZzFKMrM960CtBwfvH1ZM= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= diff --git a/vendor/github.com/rancher-sandbox/ele-testhelpers/vm/sut.go b/vendor/github.com/rancher-sandbox/ele-testhelpers/vm/sut.go index d726a6d970b..7f0b626a895 100644 --- a/vendor/github.com/rancher-sandbox/ele-testhelpers/vm/sut.go +++ b/vendor/github.com/rancher-sandbox/ele-testhelpers/vm/sut.go @@ -35,9 +35,6 @@ import ( ) const ( - grubSwapOnce = "grub2-editenv /oem/grubenv set next_entry=%s" - grubSwap = "grub2-editenv /oem/grubenv set saved_entry=%s" - Passive = "passive" Active = "active" Recovery = "recovery" @@ -145,7 +142,13 @@ func (s *SUT) ChangeBoot(b string) error { bootEntry = "recovery" } - _, err := s.command(fmt.Sprintf(grubSwap, bootEntry)) + cmd := "grub2-editenv" + _, err := s.command(fmt.Sprintf("which %s", cmd)) + if err != nil { + cmd = "grub-editenv" + } + + _, err = s.command(fmt.Sprintf("%s /oem/grubenv set saved_entry=%s", cmd, bootEntry)) Expect(err).ToNot(HaveOccurred()) return nil @@ -163,7 +166,13 @@ func (s *SUT) ChangeBootOnce(b string) error { bootEntry = "recovery" } - _, err := s.command(fmt.Sprintf(grubSwapOnce, bootEntry)) + cmd := "grub2-editenv" + _, err := s.command(fmt.Sprintf("which %s", cmd)) + if err != nil { + cmd = "grub-editenv" + } + + _, err = s.command(fmt.Sprintf("%s /oem/grubenv set next_entry=%s", cmd, bootEntry)) Expect(err).ToNot(HaveOccurred()) return nil @@ -209,14 +218,6 @@ func (s *SUT) BootFrom() string { } } -// SquashFSRecovery returns true if we are in recovery mode and booting from squashfs -func (s *SUT) SquashFSRecovery() bool { - out, err := s.command("cat /proc/cmdline") - ExpectWithOffset(1, err).ToNot(HaveOccurred()) - - return strings.Contains(out, "rd.live.squashimg") -} - func (s *SUT) GetOSRelease(ss string) string { out, err := s.Command(fmt.Sprintf("source /etc/os-release && echo $%s", ss)) Expect(err).ToNot(HaveOccurred()) @@ -286,6 +287,9 @@ func (s *SUT) command(cmd string) (string, error) { if err != nil { return "", err } + defer func() { + _ = session.Close() + }() out, err := session.CombinedOutput(cmd) if err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index 6cb0f7de962..018801f5489 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -476,7 +476,7 @@ github.com/pkg/errors # github.com/pkg/xattr v0.4.9 ## explicit; go 1.14 github.com/pkg/xattr -# github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231031082920-8b1cf3f8c16f +# github.com/rancher-sandbox/ele-testhelpers v0.0.0-20231121104300-eb56c5436c4e ## explicit; go 1.20 github.com/rancher-sandbox/ele-testhelpers/vm # github.com/rancher-sandbox/linuxkit v1.0.1