From 67e98ecbb0874273e81dec975589db1bd40976a3 Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 10 Aug 2020 21:23:42 -0400 Subject: [PATCH 1/2] kola: pass MachineOptions directly to NewMachines Prep for next patch. --- mantle/kola/harness.go | 5 ++++- mantle/platform/platform.go | 5 +---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mantle/kola/harness.go b/mantle/kola/harness.go index cd6cdb4fb7..79c9846cd2 100644 --- a/mantle/kola/harness.go +++ b/mantle/kola/harness.go @@ -896,7 +896,10 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig userdata = t.UserDataV3 } - if _, err := platform.NewMachines(c, userdata, t.ClusterSize, t.AdditionalDisks); err != nil { + options := platform.MachineOptions{ + AdditionalDisks: t.AdditionalDisks, + } + if _, err := platform.NewMachines(c, userdata, t.ClusterSize, options); err != nil { h.Fatalf("Cluster failed starting machines: %v", err) } } diff --git a/mantle/platform/platform.go b/mantle/platform/platform.go index 8c6174daa1..dfddc4af4b 100644 --- a/mantle/platform/platform.go +++ b/mantle/platform/platform.go @@ -354,7 +354,7 @@ func CopyDirToMachine(inputdir string, m Machine, destdir string) error { // NewMachines spawns n instances in cluster c, with // each instance passed the same userdata. -func NewMachines(c Cluster, userdata *conf.UserData, n int, addDisks []string) ([]Machine, error) { +func NewMachines(c Cluster, userdata *conf.UserData, n int, options MachineOptions) ([]Machine, error) { var wg sync.WaitGroup mchan := make(chan Machine, n) @@ -364,9 +364,6 @@ func NewMachines(c Cluster, userdata *conf.UserData, n int, addDisks []string) ( wg.Add(1) go func() { defer wg.Done() - options := MachineOptions{ - AdditionalDisks: addDisks, - } m, err := c.NewMachineWithOptions(userdata, options) if err != nil { errchan <- err From 2a5a09cf3e55db369f4ce302c730c787cc1dc0be Mon Sep 17 00:00:00 2001 From: Jonathan Lebon Date: Mon, 10 Aug 2020 21:25:41 -0400 Subject: [PATCH 2/2] kola: add minMemory in kola.json (external tests) For the root reprovisioning work, we need to be able to temporarily save the rootfs into RAM. This means we need at least 4G of RAM. Add a new `minMemory` field which tells the platform to make sure the machine provisioned has at least that amount of memory. On QEMU, this directly controls the memory of the machine. On cloud platforms, it would affect the instance type to use. But for now, we only actually handle this field on QEMU. --- mantle/kola/README-kola-ext.md | 10 ++++++++-- mantle/kola/harness.go | 3 +++ mantle/kola/register/register.go | 3 +++ mantle/platform/machine/unprivqemu/cluster.go | 2 ++ mantle/platform/platform.go | 1 + 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mantle/kola/README-kola-ext.md b/mantle/kola/README-kola-ext.md index 9b4380694c..5e60aee4d3 100644 --- a/mantle/kola/README-kola-ext.md +++ b/mantle/kola/README-kola-ext.md @@ -105,8 +105,9 @@ Here's an example `kola.json`: { "architectures": "!s390x ppc64le", "platforms": "qemu-unpriv", - "tags": "sometagname needs-internet othertag" - "additionalDisks": [ "5G" ] + "tags": "sometagname needs-internet othertag", + "additionalDisks": [ "5G" ], + "minMemory": 4096 } ``` @@ -129,6 +130,11 @@ Currently only the `qemu` platform enforces this restriction. The `additionalDisks` key has the same semantics as the `--add-disk` argument to `qemuexec`. It is currently only supported on `qemu-unpriv`. +The `minMemory` key takes a size in MB and ensures that an instance type +with at least the specified amount of memory is used. On QEMU, this is +equivalent to the `--memory` argument to `qemuexec`. This is currently +only enforced on `qemu-unpriv`. + More recently, you can also (useful for shell scripts) include the JSON file inline per test, like this: diff --git a/mantle/kola/harness.go b/mantle/kola/harness.go index 79c9846cd2..21c1597687 100644 --- a/mantle/kola/harness.go +++ b/mantle/kola/harness.go @@ -534,6 +534,7 @@ type externalTestMeta struct { Distros string `json:",distros,omitempty"` Tags string `json:",tags,omitempty"` AdditionalDisks []string `json:",additionalDisks,omitempty"` + MinMemory int `json:",minMemory,omitempty"` } // metadataFromTestBinary extracts JSON-in-comment like: @@ -662,6 +663,7 @@ ExecStart=%s Tags: []string{"external"}, AdditionalDisks: targetMeta.AdditionalDisks, + MinMemory: targetMeta.MinMemory, Run: func(c cluster.TestCluster) { mach := c.Machines()[0] @@ -898,6 +900,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig options := platform.MachineOptions{ AdditionalDisks: t.AdditionalDisks, + MinMemory: t.MinMemory, } if _, err := platform.NewMachines(c, userdata, t.ClusterSize, options); err != nil { h.Fatalf("Cluster failed starting machines: %v", err) diff --git a/mantle/kola/register/register.go b/mantle/kola/register/register.go index baee1e5669..bc209e8b61 100644 --- a/mantle/kola/register/register.go +++ b/mantle/kola/register/register.go @@ -69,6 +69,9 @@ type Test struct { // "5G"]) -- defaults to none. AdditionalDisks []string + // Minimum amount of memory required for test. + MinMemory int + // ExternalTest is a path to a binary that will be uploaded ExternalTest string // DependencyDir is a path to directory that will be uploaded, normally used by external tests diff --git a/mantle/platform/machine/unprivqemu/cluster.go b/mantle/platform/machine/unprivqemu/cluster.go index e2c2502f38..9716c1cd72 100644 --- a/mantle/platform/machine/unprivqemu/cluster.go +++ b/mantle/platform/machine/unprivqemu/cluster.go @@ -112,6 +112,8 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl return nil, errors.Wrapf(err, "parsing memory option") } builder.Memory = int(memory) + } else if options.MinMemory != 0 { + builder.Memory = options.MinMemory } channel := "virtio" diff --git a/mantle/platform/platform.go b/mantle/platform/platform.go index dfddc4af4b..a76ee49909 100644 --- a/mantle/platform/platform.go +++ b/mantle/platform/platform.go @@ -156,6 +156,7 @@ type Flight interface { type MachineOptions struct { AdditionalDisks []string + MinMemory int } // SystemdDropin is a userdata type agnostic struct representing a systemd dropin