sparkles: custom user bind and ephemeral mounts (#692)

*  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 <oz@spectrocloud.com>

* Add the custom user mount to /cos/run/cos-layout.env

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Add docs for custom user mounts in configuration example

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Reuse test_install function

DRY the code, change how we call the function install_test

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Enable custom mount tests and install tests

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Enable tests in CI

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Remove duplicate if check

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Remove uneeded fmt.Println ...

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Use separate label for custom mounts

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Earthfile - DRY ginkgo

We repeat this a more than twice so just extract to own
target...

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Correct return type for  ContainElements

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Remove CLOUD_INIT from custom mounts test

This is not needed here.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* Fix qemu-test-* earthly targets

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 Fix CPU passing to VM

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 🔧 remove apt cache after install qemu

Helps deal with space running out in the CI.

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

* 📖 Document custom mounts

Signed-off-by: Oz Tiram <oz@spectrocloud.com>

---------

Signed-off-by: Oz Tiram <oz@spectrocloud.com>
Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
This commit is contained in:
Oz Tiram
2023-02-03 11:04:02 +01:00
committed by Itxaka
parent a37f68cf00
commit f8f993f7c5

View File

@@ -42,7 +42,8 @@ go-deps:
SAVE ARTIFACT go.mod AS LOCAL go.mod SAVE ARTIFACT go.mod AS LOCAL go.mod
SAVE ARTIFACT go.sum AS LOCAL go.sum SAVE ARTIFACT go.sum AS LOCAL go.sum
test:
ginkgo:
FROM +go-deps FROM +go-deps
WORKDIR /build WORKDIR /build
RUN go get github.com/onsi/gomega/... 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/generators@v2.1.4
RUN go get github.com/onsi/ginkgo/v2/ginkgo/labels@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 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 +luet/luet /usr/bin/luet
COPY . . COPY . .
ENV ACK_GINKGO_DEPRECATIONS=2.5.1 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 # usage e.g. ./earthly.sh +run-qemu-datasource-tests --FLAVOR=alpine-opensuse-leap --FROM_ARTIFACTS=true
run-qemu-datasource-tests: run-qemu-datasource-tests:
FROM opensuse/leap FROM +ginkgo
RUN apt install -y qemu-system-x86 qemu-utils golang git
WORKDIR /test WORKDIR /test
RUN zypper in -y qemu-x86 qemu-arm qemu-tools go git
ARG FLAVOR ARG FLAVOR
ARG TEST_SUITE=autoinstall-test ARG TEST_SUITE=autoinstall-test
ENV FLAVOR=$FLAVOR ENV FLAVOR=$FLAVOR
ENV SSH_PORT=60022 ENV SSH_PORT=60023
ENV CREATE_VM=true ENV CREATE_VM=true
ARG CLOUD_CONFIG="./tests/assets/autoinstall.yaml" ARG CLOUD_CONFIG="./tests/assets/autoinstall.yaml"
ENV USE_QEMU=true ENV USE_QEMU=true
@@ -466,19 +476,34 @@ run-qemu-datasource-tests:
ELSE ELSE
ENV DATASOURCE=/test/build/datasource.iso ENV DATASOURCE=/test/build/datasource.iso
END 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 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: run-qemu-netboot-test:
FROM ubuntu FROM +ginkgo
COPY . /test COPY . /test
WORKDIR /test WORKDIR /test
@@ -487,7 +512,7 @@ run-qemu-netboot-test:
ARG VERSION=$(cat VERSION) ARG VERSION=$(cat VERSION)
RUN apt update 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 # This is the IP at which qemu vm can see the host
ARG IP="10.0.2.2" ARG IP="10.0.2.2"
@@ -504,7 +529,7 @@ run-qemu-netboot-test:
ENV USE_QEMU=true ENV USE_QEMU=true
ARG TEST_SUITE=netboot-test ARG TEST_SUITE=netboot-test
ENV GOPATH="/go" 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 # TODO: use --pull or something to cache the python image in Earthly
WITH DOCKER WITH DOCKER
@@ -514,9 +539,8 @@ run-qemu-netboot-test:
END END
run-qemu-test: run-qemu-test:
FROM opensuse/leap FROM +ginkgo
WORKDIR /test RUN apt install -y qemu-system-x86 qemu-utils git && apt clean
RUN zypper in -y qemu-x86 qemu-arm qemu-tools go git
ARG FLAVOR ARG FLAVOR
ARG TEST_SUITE=upgrade-with-cli ARG TEST_SUITE=upgrade-with-cli
ARG CONTAINER_IMAGE ARG CONTAINER_IMAGE
@@ -528,18 +552,15 @@ run-qemu-test:
ENV GOPATH="/go" ENV GOPATH="/go"
COPY . . COPY . .
RUN go get github.com/onsi/gomega/... IF [ -e /build/kairos.iso ]
RUN go get github.com/onsi/ginkgo/v2/ginkgo/internal@v2.1.4 ENV ISO=/build/kairos.iso
RUN go get github.com/onsi/ginkgo/v2/ginkgo/generators@v2.1.4 ELSE
RUN go get github.com/onsi/ginkgo/v2/ginkgo/labels@v2.1.4 COPY +iso/kairos.iso kairos.iso
RUN go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo ENV ISO=/build/kairos.iso
END
ARG ISO=$(ls /test/build/*.iso) RUN pwd && ls -l && ls -l build
ENV ISO=$ISO RUN PATH=$PATH:$GOPATH/bin ginkgo -v --label-filter "$TEST_SUITE" --fail-fast -r ./tests/
RUN PATH=$PATH:$GOPATH/bin ginkgo --label-filter "$TEST_SUITE" --fail-fast -r ./tests/
### ###
### Artifacts targets ### Artifacts targets