From f8f993f7c5616db68be3ad9291c5cda2c3723ba6 Mon Sep 17 00:00:00 2001 From: Oz Tiram Date: Fri, 3 Feb 2023 11:04:02 +0100 Subject: [PATCH] sparkles: custom user bind and ephemeral mounts (#692) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :sparkles: custom user bind and ephemeral mounts Users can now specify custom and ephemeral mounts in cloud-init under the `install` section, e.g.: ``` users: - name: kairos ... install: auto: true device: "auto" bind_mounts: - /mnt/bind1 - /mnt/bind2 ephemeral_mounts: - /mnt/ephemeral - /mnt/ephemeral2 ... ``` Ephemeral mounts are mounted as RW - but changes are discarded when the machine is restart. Bind mounts will persist changes after restarted. This is a fix for #210 Signed-off-by: Oz Tiram * Add the custom user mount to /cos/run/cos-layout.env Signed-off-by: Oz Tiram * Add docs for custom user mounts in configuration example Signed-off-by: Oz Tiram * Reuse test_install function DRY the code, change how we call the function install_test Signed-off-by: Oz Tiram * Enable custom mount tests and install tests Signed-off-by: Oz Tiram * Enable tests in CI Signed-off-by: Oz Tiram * Remove duplicate if check Signed-off-by: Oz Tiram * Remove uneeded fmt.Println ... Signed-off-by: Oz Tiram * Use separate label for custom mounts Signed-off-by: Oz Tiram * 🔧 Earthfile - DRY ginkgo We repeat this a more than twice so just extract to own target... Signed-off-by: Oz Tiram * Correct return type for ContainElements Signed-off-by: Oz Tiram * Remove CLOUD_INIT from custom mounts test This is not needed here. Signed-off-by: Oz Tiram * Fix qemu-test-* earthly targets Signed-off-by: Oz Tiram * 🔧 Fix CPU passing to VM Signed-off-by: Oz Tiram * 🔧 remove apt cache after install qemu Helps deal with space running out in the CI. Signed-off-by: Oz Tiram * :book: Document custom mounts Signed-off-by: Oz Tiram --------- Signed-off-by: Oz Tiram Co-authored-by: Ettore Di Giacinto --- Earthfile | 79 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 29 deletions(-) diff --git a/Earthfile b/Earthfile index 758a09c..f2c5c2e 100644 --- a/Earthfile +++ b/Earthfile @@ -42,7 +42,8 @@ go-deps: SAVE ARTIFACT go.mod AS LOCAL go.mod SAVE ARTIFACT go.sum AS LOCAL go.sum -test: + +ginkgo: FROM +go-deps WORKDIR /build RUN go get github.com/onsi/gomega/... @@ -50,6 +51,15 @@ test: RUN go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.4 RUN go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.4 RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo + +test: + FROM +ginkgo + WORKDIR /build + RUN go get github.com/onsi/gomega/... + RUN go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.4 + RUN go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.4 + RUN go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.4 + RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo COPY +luet/luet /usr/bin/luet COPY . . ENV ACK_GINKGO_DEPRECATIONS=2.5.1 @@ -437,13 +447,13 @@ linux-bench-scan: ### # usage e.g. ./earthly.sh +run-qemu-datasource-tests --FLAVOR=alpine-opensuse-leap --FROM_ARTIFACTS=true run-qemu-datasource-tests: - FROM opensuse/leap + FROM +ginkgo + RUN apt install -y qemu-system-x86 qemu-utils golang git WORKDIR /test - RUN zypper in -y qemu-x86 qemu-arm qemu-tools go git ARG FLAVOR ARG TEST_SUITE=autoinstall-test ENV FLAVOR=$FLAVOR - ENV SSH_PORT=60022 + ENV SSH_PORT=60023 ENV CREATE_VM=true ARG CLOUD_CONFIG="./tests/assets/autoinstall.yaml" ENV USE_QEMU=true @@ -466,19 +476,34 @@ run-qemu-datasource-tests: ELSE ENV DATASOURCE=/test/build/datasource.iso END - RUN go get github.com/onsi/gomega/... - RUN go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.4 - RUN go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.4 - RUN go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.4 - RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo - ENV CLOUD_INIT=/tests/tests/$CLOUD_CONFIG - RUN PATH=$PATH:$GOPATH/bin ginkgo --label-filter "$TEST_SUITE" --fail-fast -r ./tests/ + RUN PATH=$PATH:$GOPATH/bin ginkgo -v --label-filter "$TEST_SUITE" --fail-fast -r ./tests/ + +run-qemu-custom-mount-tests: + FROM +ginkgo + RUN apt install -y qemu-system-x86 qemu-utils git && apt clean + ARG FLAVOR + + COPY . . + RUN ls -liah + IF [ -e /build/kairos.iso ] + ENV ISO=/build/kairos.iso + ELSE + COPY +iso/kairos.iso kairos.iso + ENV ISO=/build/kairos.iso + END + + ENV GOPATH="/go" + ARG TEST_SUITE=custom-mounts-test + ENV SSH_PORT=60024 + ENV CREATE_VM=true + ENV USE_QEMU=true + RUN pwd && ls -liah + RUN PATH=$PATH:$GOPATH/bin ginkgo -v --label-filter custom-mounts-test --fail-fast -r ./tests/ run-qemu-netboot-test: - FROM ubuntu - + FROM +ginkgo COPY . /test WORKDIR /test @@ -487,7 +512,7 @@ run-qemu-netboot-test: ARG VERSION=$(cat VERSION) RUN apt update - RUN apt install -y qemu qemu-utils qemu-system golang git + RUN apt install -y qemu qemu-utils qemu-system git && apt clean # This is the IP at which qemu vm can see the host ARG IP="10.0.2.2" @@ -504,7 +529,7 @@ run-qemu-netboot-test: ENV USE_QEMU=true ARG TEST_SUITE=netboot-test ENV GOPATH="/go" - RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo + # TODO: use --pull or something to cache the python image in Earthly WITH DOCKER @@ -514,9 +539,8 @@ run-qemu-netboot-test: END run-qemu-test: - FROM opensuse/leap - WORKDIR /test - RUN zypper in -y qemu-x86 qemu-arm qemu-tools go git + FROM +ginkgo + RUN apt install -y qemu-system-x86 qemu-utils git && apt clean ARG FLAVOR ARG TEST_SUITE=upgrade-with-cli ARG CONTAINER_IMAGE @@ -528,18 +552,15 @@ run-qemu-test: ENV GOPATH="/go" - COPY . . - RUN go get github.com/onsi/gomega/... - RUN go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.4 - RUN go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.4 - RUN go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.4 - RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo - - ARG ISO=$(ls /test/build/*.iso) - ENV ISO=$ISO - - RUN PATH=$PATH:$GOPATH/bin ginkgo --label-filter "$TEST_SUITE" --fail-fast -r ./tests/ + IF [ -e /build/kairos.iso ] + ENV ISO=/build/kairos.iso + ELSE + COPY +iso/kairos.iso kairos.iso + ENV ISO=/build/kairos.iso + END + RUN pwd && ls -l && ls -l build + RUN PATH=$PATH:$GOPATH/bin ginkgo -v --label-filter "$TEST_SUITE" --fail-fast -r ./tests/ ### ### Artifacts targets