Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kola: add additionalDisks support in kola.json #1573

Merged
merged 3 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mantle/cmd/kola/spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ func runSpawn(cmd *cobra.Command, args []string) error {
}
// use qemu-specific interface only if needed
if strings.HasPrefix(kolaPlatform, "qemu") && (spawnMachineOptions != "" || !spawnRemove) {
var machineOpts platform.MachineOptions
machineOpts := platform.QemuMachineOptions{
DisablePDeathSig: !spawnRemove,
}
if spawnMachineOptions != "" {
b, err := ioutil.ReadFile(spawnMachineOptions)
if err != nil {
Expand All @@ -184,7 +186,7 @@ func runSpawn(cmd *cobra.Command, args []string) error {

switch qc := cluster.(type) {
case *unprivqemu.Cluster:
mach, err = qc.NewMachineWithOptions(userdata, machineOpts, spawnRemove)
mach, err = qc.NewMachineWithQemuOptions(userdata, machineOpts)
default:
plog.Fatalf("unreachable: qemu cluster %v unknown type", qc)
}
Expand Down
21 changes: 13 additions & 8 deletions mantle/kola/README-kola-ext.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,29 @@ Here's an example `kola.json`:
```json
{
"architectures": "!s390x ppc64le",
"platforms": "qemu-unpriv"
"platforms": "qemu-unpriv",
"additionalDisks": [ "5G" ]
}
```

The only supported keys are those two; either or none may be provided as well.
Each value is a single string, which is a whitespace-separated list.
The reason to use a single string (instead of a native JSON list)
is that by providing `!` at the front of the string, the value instead
declares exclusions (`ExclusiveArchitectures` instead of `Architectures` in
reference to kola internals.
The only supported keys are those three; any or none may be provided as
well. For `architectures` and `platforms`, each value is a single
string, which is a whitespace-separated list. The reason to use a
single string (instead of a native JSON list) is that by providing `!`
at the front of the string, the value instead declares exclusions
(`ExclusiveArchitectures` instead of `Architectures` in reference to
kola internals.

The `additionalDisks` key has the same semantics as the `--add-disk`
argument to `qemuexec`. It is currently only supported on `qemu-unpriv`.

More recently, you can also (useful for shell scripts) include the JSON file
inline per test, like this:

```sh
#!/bin/bash
set -xeuo pipefail
# kola: { "architectures": "x86_64", "platforms": ["aws", "gcp"] }
# kola: { "architectures": "x86_64", "platforms": "aws gcp"] }
test code here
```

Expand Down
15 changes: 9 additions & 6 deletions mantle/kola/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,13 @@ func RunUpgradeTests(patterns []string, pltfrm, outputDir string, propagateTestE
return runProvidedTests(register.UpgradeTests, patterns, pltfrm, outputDir, propagateTestErrors)
}

// externalTestMeta is parsed from kola.yaml in external tests
// externalTestMeta is parsed from kola.json in external tests
type externalTestMeta struct {
Architectures string `json:",architectures,omitempty"`
Platforms string `json:",platforms,omitempty"`
Distros string `json:",distros,omitempty"`
Tags string `json:",tags,omitempty"`
Architectures string `json:",architectures,omitempty"`
Platforms string `json:",platforms,omitempty"`
Distros string `json:",distros,omitempty"`
Tags string `json:",tags,omitempty"`
AdditionalDisks []string `json:",additionalDisks,omitempty"`
}

// metadataFromTestBinary extracts JSON-in-comment like:
Expand Down Expand Up @@ -655,6 +656,8 @@ ExecStart=%s
DependencyDir: dependencydir,
Tags: []string{"external"},

AdditionalDisks: targetMeta.AdditionalDisks,

Run: func(c cluster.TestCluster) {
mach := c.Machines()[0]
plog.Debugf("Running kolet")
Expand Down Expand Up @@ -888,7 +891,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
userdata = t.UserDataV3
}

if _, err := platform.NewMachines(c, userdata, t.ClusterSize); err != nil {
if _, err := platform.NewMachines(c, userdata, t.ClusterSize, t.AdditionalDisks); err != nil {
h.Fatalf("Cluster failed starting machines: %v", err)
}
}
Expand Down
4 changes: 4 additions & 0 deletions mantle/kola/register/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type Test struct {
Flags []Flag // special-case options for this test
Tags []string // list of tags that can be matched against -- defaults to none

// Sizes of additional empty disks to attach to the node (e.g. ["1G",
// "5G"]) -- defaults to none.
AdditionalDisks []string

// 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
Expand Down
21 changes: 4 additions & 17 deletions mantle/kola/tests/ignition/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/coreos/mantle/kola/register"
"github.com/coreos/mantle/platform"
"github.com/coreos/mantle/platform/conf"
"github.com/coreos/mantle/platform/machine/unprivqemu"
"github.com/coreos/mantle/system"
"github.com/coreos/mantle/util"
)
Expand Down Expand Up @@ -57,15 +56,12 @@ func testMountDisks(c cluster.TestCluster) {
setupIgnitionConfig()

options := platform.MachineOptions{
AdditionalDisks: []platform.Disk{
{Size: "1024M", DeviceOpts: []string{"serial=secondary-disk"}},
{Size: "1024M", DeviceOpts: []string{"serial=tertiary-disk"}},
},
AdditionalDisks: []string{"1024M", "1024M"},
}

ignDisks := []ignv3types.Disk{
{
Device: "/dev/disk/by-id/virtio-secondary-disk",
Device: "/dev/disk/by-id/virtio-disk1",
Partitions: []ignv3types.Partition{
{
Label: util.StrToPtr("CONTR"),
Expand All @@ -76,7 +72,7 @@ func testMountDisks(c cluster.TestCluster) {
WipeTable: util.BoolToPtr(true),
},
{
Device: "/dev/disk/by-id/virtio-tertiary-disk",
Device: "/dev/disk/by-id/virtio-disk2",
Partitions: []ignv3types.Partition{
{
Label: util.StrToPtr("LOG"),
Expand Down Expand Up @@ -153,16 +149,7 @@ func createClusterValidate(c cluster.TestCluster, options platform.MachineOption
c.Fatal(err)
}

switch pc := c.Cluster.(type) {
// These cases have to be separated because when put together to the same case statement
// the golang compiler no longer checks that the individual types in the case have the
// NewMachineWithOptions function, but rather whether platform.Cluster does which fails
case *unprivqemu.Cluster:
m, err = pc.NewMachineWithOptions(conf.Ignition(string(serializedConfig)), options, true)
default:
c.Fatal("unknown cluster type")
}

m, err = c.NewMachineWithOptions(conf.Ignition(string(serializedConfig)), options)
if err != nil {
c.Fatal(err)
}
Expand Down
17 changes: 3 additions & 14 deletions mantle/kola/tests/misc/raid.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@ import (
"github.com/coreos/mantle/kola/register"
"github.com/coreos/mantle/platform"
"github.com/coreos/mantle/platform/conf"
"github.com/coreos/mantle/platform/machine/unprivqemu"
)

var (
raidRootUserData = conf.ContainerLinuxConfig(`storage:
disks:
- device: "/dev/disk/by-id/virtio-secondary"
- device: "/dev/disk/by-id/virtio-disk1"
wipe_table: true
partitions:
- label: root1
Expand Down Expand Up @@ -108,19 +107,9 @@ func RootOnRaid(c cluster.TestCluster) {
var m platform.Machine
var err error
options := platform.MachineOptions{
AdditionalDisks: []platform.Disk{
{Size: "520M", DeviceOpts: []string{"serial=secondary"}},
},
}
switch pc := c.Cluster.(type) {
// These cases have to be separated because when put together to the same case statement
// the golang compiler no longer checks that the individual types in the case have the
// NewMachineWithOptions function, but rather whether platform.Cluster does which fails
case *unprivqemu.Cluster:
m, err = pc.NewMachineWithOptions(raidRootUserData, options, true)
default:
c.Fatal("unknown cluster type")
AdditionalDisks: []string{"520M"},
}
m, err = c.NewMachineWithOptions(raidRootUserData, options)
if err != nil {
c.Fatal(err)
}
Expand Down
7 changes: 4 additions & 3 deletions mantle/kola/tests/rhcos/luks.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func setupTangMachine(c cluster.TestCluster) (string, string) {
var thumbprint []byte
var tangAddress string

options := platform.MachineOptions{
options := platform.QemuMachineOptions{
HostForwardPorts: []platform.HostForwardPort{
{Service: "ssh", HostPort: 0, GuestPort: 22},
{Service: "tang", HostPort: 0, GuestPort: 80},
Expand All @@ -96,9 +96,10 @@ func setupTangMachine(c cluster.TestCluster) (string, string) {
switch pc := c.Cluster.(type) {
// These cases have to be separated because when put together to the same case statement
// the golang compiler no longer checks that the individual types in the case have the
// NewMachineWithOptions function, but rather whether platform.Cluster does which fails
// NewMachineWithQemuOptions function, but rather whether platform.Cluster
// does which fails
case *unprivqemu.Cluster:
m, err = pc.NewMachineWithOptions(ignition, options, true)
m, err = pc.NewMachineWithQemuOptions(ignition, options)
for _, hfp := range options.HostForwardPorts {
if hfp.Service == "tang" {
tangAddress = fmt.Sprintf("10.0.2.2:%d", hfp.HostPort)
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/aws/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package aws

import (
"errors"
"os"
"path/filepath"

Expand Down Expand Up @@ -77,6 +78,13 @@ func (ac *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
return mach, nil
}

func (ac *cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform aws does not yet support additional disks")
}
return ac.NewMachine(userdata)
}

func (ac *cluster) Destroy() {
ac.BaseCluster.Destroy()
ac.flight.DelCluster(ac)
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/azure/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package azure

import (
"errors"
"fmt"
"math/rand"
"os"
Expand Down Expand Up @@ -83,6 +84,13 @@ func (ac *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
return mach, nil
}

func (ac *cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform azure does not yet support additional disks")
}
return ac.NewMachine(userdata)
}

func (ac *cluster) Destroy() {
ac.BaseCluster.Destroy()
if e := ac.flight.api.TerminateResourceGroup(ac.ResourceGroup); e != nil {
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/do/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package do
import (
"context"
"crypto/rand"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -87,6 +88,13 @@ func (dc *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
return mach, nil
}

func (dc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform do does not yet support additional disks")
}
return dc.NewMachine(userdata)
}

func (dc *cluster) vmname() string {
b := make([]byte, 5)
rand.Read(b)
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/esx/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package esx

import (
"errors"
"fmt"
"math/rand"
"os"
Expand Down Expand Up @@ -90,6 +91,13 @@ ExecStart=/usr/bin/bash -c 'echo "COREOS_ESX_IPV4_PRIVATE_0=$(ip addr show ens19
return mach, nil
}

func (ec *cluster) NewMachineWithOptions(userdata *platformConf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform esx does not yet support additional disks")
}
return ec.NewMachine(userdata)
}

func (ec *cluster) Destroy() {
ec.BaseCluster.Destroy()
ec.flight.DelCluster(ec)
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/gcloud/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package gcloud

import (
"errors"
"os"
"path/filepath"

Expand Down Expand Up @@ -90,6 +91,13 @@ func (gc *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
return gm, nil
}

func (gc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform gce does not yet support additional disks")
}
return gc.NewMachine(userdata)
}

func (gc *cluster) Destroy() {
gc.BaseCluster.Destroy()
gc.flight.DelCluster(gc)
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/openstack/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package openstack

import (
"crypto/rand"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -79,6 +80,13 @@ func (oc *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
return mach, nil
}

func (oc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform openstack does not yet support additional disks")
}
return oc.NewMachine(userdata)
}

func (oc *cluster) vmname() string {
b := make([]byte, 5)
rand.Read(b)
Expand Down
8 changes: 8 additions & 0 deletions mantle/platform/machine/packet/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package packet

import (
"crypto/rand"
"errors"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -111,6 +112,13 @@ func (pc *cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
return mach, nil
}

func (pc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
if len(options.AdditionalDisks) > 0 {
return nil, errors.New("platform packet does not yet support additional disks")
}
return pc.NewMachine(userdata)
}

func (pc *cluster) vmname() string {
b := make([]byte, 5)
rand.Read(b)
Expand Down
Loading