From f742a9a953a4d49c77dda16f34f8f82b56670391 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Fri, 10 Jul 2020 19:02:44 -0400 Subject: [PATCH] kola: use platform.Conf instead of an Ignition spec directly The `platform.Conf` type allows abstracting over the different Ignition versions so that different tests can use different versions. Using it instead of the Ignition type directly means that we can now use the 3.2-experimental spec in external tests. This is needed for testing the new LUKS support in Ignition[1] and the related rootfs-on-complex-devices work[2]. [1] https://github.com/coreos/ignition/pull/960 [2] https://github.com/coreos/fedora-coreos-config/pull/503 Closes: #1589 --- mantle/kola/harness.go | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/mantle/kola/harness.go b/mantle/kola/harness.go index c0f04d2b25..e9e4575d41 100644 --- a/mantle/kola/harness.go +++ b/mantle/kola/harness.go @@ -31,8 +31,6 @@ import ( "github.com/kballard/go-shellquote" "github.com/pkg/errors" - ignv3 "github.com/coreos/ignition/v2/config/v3_0" - ignv3types "github.com/coreos/ignition/v2/config/v3_0/types" "github.com/coreos/mantle/harness" "github.com/coreos/mantle/harness/reporters" "github.com/coreos/mantle/kola/cluster" @@ -57,7 +55,6 @@ import ( "github.com/coreos/mantle/platform/machine/unprivqemu" "github.com/coreos/mantle/sdk" "github.com/coreos/mantle/system" - "github.com/coreos/mantle/util" ) // InstalledTestsDir is a directory where "installed" external @@ -603,7 +600,7 @@ func runExternalTest(c cluster.TestCluster, mach platform.Machine) error { } func registerExternalTest(testname, executable, dependencydir, ignition string, baseMeta externalTestMeta) error { - ignc3, _, err := ignv3.Parse([]byte(ignition)) + config, err := conf.Ignition(ignition).Render("", Options.IgnitionVersion == "v2") if err != nil { return errors.Wrapf(err, "Parsing config.ign") } @@ -627,26 +624,7 @@ Environment=KOLA_UNIT=%s Environment=%s=%s ExecStart=%s `, KoletExtTestUnit, kolaExtBinDataEnv, kolaExtBinDataDir, remotepath) - runextconfig := ignv3types.Config{ - Ignition: ignv3types.Ignition{ - Version: "3.0.0", - }, - Systemd: ignv3types.Systemd{ - Units: []ignv3types.Unit{ - { - Name: KoletExtTestUnit, - Contents: &unit, - Enabled: util.BoolToPtr(false), - }, - }, - }, - } - - finalIgn := ignv3.Merge(ignc3, runextconfig) - serializedIgn, err := json.Marshal(finalIgn) - if err != nil { - return errors.Wrapf(err, "serializing ignition") - } + config.AddSystemdUnit(KoletExtTestUnit, unit, conf.Enable) t := ®ister.Test{ Name: testname, @@ -677,7 +655,7 @@ ExecStart=%s } }, - UserDataV3: conf.Ignition(string(serializedIgn)), + UserDataV3: conf.Ignition(config.String()), } // To avoid doubling the duplication here with register.Test, we support