From 814c442bbe3a063a599b79b4575cf3a98145daa9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 21 Jul 2022 12:55:34 -0400 Subject: [PATCH] kola: Change `--oscontainer` to use new ostree native containers Quite a while ago we added this special case code to kola which learned how to do in-place updates to the weird bespoke "ostree repo in container" OCP/RHCOS-specific container image. A huge benefit of the change to use ostree-native containers is that this approach can now be shared across FCOS/RHCOS. (Also, rpm-ostree natively understands this, so it's much much more efficient and less awkward than the wrappers we had in `pivot` around rpm-ostree) But the benefits get even larger: this issue: https://github.com/coreos/coreos-assembler/issues/2685 proposes rethinking of our pipeline to more cleanly split up "build OS update container" from "build disk images". With this, it becomes extra convenient to do a flow of: - build OS update container, push to registry - `kola run -p stable --oscontainer quay.io/fcos-devel/testos@sha256...` IOW we're not generating a disk image to test the OS update - we're using the *stable* disk image and doing an in-place update before we run tests. Now...as of right now nothing in the pipeline passes this flag, so the code won't be used (except for manual testing). Suddenly with this, the number of tests we can run roughly *doubles*. For example, we can run e.g. `kola run rpm-ostree` both with and without `--oscontainer`. In most cases, things should be the same. But, I think it will be interesting to try to explictly use this for at least some tests; it's almost a full generalization of the `kola run-upgrades` bits. --- mantle/cmd/kola/options.go | 4 ---- mantle/platform/cluster.go | 23 ++++++++++------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/mantle/cmd/kola/options.go b/mantle/cmd/kola/options.go index bbf58f51d0..ebdddebecd 100644 --- a/mantle/cmd/kola/options.go +++ b/mantle/cmd/kola/options.go @@ -289,10 +289,6 @@ func syncOptionsImpl(useCosa bool) error { }) } - if kola.Options.OSContainer != "" && kola.Options.Distribution != "rhcos" { - return fmt.Errorf("oscontainer is only supported on rhcos") - } - if kola.Options.Distribution == "" { kola.Options.Distribution = kolaDistros[0] } else if kola.Options.Distribution == "scos" { diff --git a/mantle/platform/cluster.go b/mantle/platform/cluster.go index 97b0fb5940..ebdc3786f9 100644 --- a/mantle/platform/cluster.go +++ b/mantle/platform/cluster.go @@ -221,25 +221,22 @@ enabled = false`, 0644) } if bc.bf.baseopts.OSContainer != "" { - if bc.Distribution() != "rhcos" { - return nil, fmt.Errorf("oscontainer is only supported on the rhcos distribution") - } - conf.AddSystemdUnitDropin("pivot.service", "00-before-sshd.conf", `[Unit] -Before=sshd.service`) - conf.AddSystemdUnit("pivot.service", "", platformConf.Enable) - conf.AddSystemdUnit("pivot-write-reboot-needed.service", `[Unit] -Description=Touch /run/pivot/reboot-needed -ConditionFirstBoot=true + conf.AddSystemdUnit("kola-container-rebase.service", fmt.Sprintf(`[Unit] +Description=Rebase to target container +ConditionPathExists=!/etc/kola-rebase-done +Before=sshd.service +Wants=network-online.target +After=network-online.target [Service] Type=oneshot -ExecStart=/usr/bin/mkdir -p /run/pivot -ExecStart=/usr/bin/touch /run/pivot/reboot-needed +ExecStart=rpm-ostree rebase --experimental %s +ExecStart=touch /etc/kola-rebase-done +ExecStart=systemctl reboot [Install] WantedBy=multi-user.target -`, platformConf.Enable) - conf.AddFile("/etc/pivot/image-pullspec", bc.bf.baseopts.OSContainer, 0644) +`, bc.bf.baseopts.OSContainer), platformConf.Enable) } if conf.IsIgnition() {