Skip to content

Commit 9131ca7

Browse files
committed
mantle/kola: add InstanceType to PlatformOptions for external tests
Add an `InstanceType` field to `PlatformOptions` to allow external tests to override the instance type used in `kola run`. This is useful for cases where a specific test needs to run on a different (potentially more expensive) instance type. Support for this is currently limited to the Azure Platform. Also, fix the `MultiPathDisk` check for the qemu-iso platform. The check is now correctly performed in the `NewMachineWithOptions` function, since `MultiPathDisk` is part of `platform.MachineOptions`.
1 parent b0c667e commit 9131ca7

File tree

11 files changed

+43
-6
lines changed

11 files changed

+43
-6
lines changed

mantle/kola/harness.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,7 @@ type externalTestMeta struct {
10271027
Conflicts []string `json:"conflicts" yaml:"conflicts"`
10281028
AllowConfigWarnings bool `json:"allowConfigWarnings" yaml:"allowConfigWarnings"`
10291029
NoInstanceCreds bool `json:"noInstanceCreds" yaml:"noInstanceCreds"`
1030+
InstanceType string `json:"instanceType" yaml:"instanceType"`
10301031
Description string `json:"description" yaml:"description"`
10311032
}
10321033

@@ -1236,6 +1237,7 @@ ExecStart=%s
12361237
AdditionalNics: targetMeta.AdditionalNics,
12371238
AppendKernelArgs: targetMeta.AppendKernelArgs,
12381239
AppendFirstbootKernelArgs: targetMeta.AppendFirstbootKernelArgs,
1240+
InstanceType: targetMeta.InstanceType,
12391241
NonExclusive: !targetMeta.Exclusive,
12401242
Conflicts: targetMeta.Conflicts,
12411243

@@ -1757,6 +1759,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
17571759
AppendKernelArgs: t.AppendKernelArgs,
17581760
AppendFirstbootKernelArgs: t.AppendFirstbootKernelArgs,
17591761
SkipStartMachine: true,
1762+
InstanceType: t.InstanceType,
17601763
}
17611764

17621765
// Providers sometimes fail to bring up a machine within a

mantle/kola/register/register.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ type Test struct {
117117
// Conflicts is non-empty iff nonexclusive is true
118118
// Contains the tests that conflict with this particular test
119119
Conflicts []string
120+
121+
// If provided, this test will be run on the target instance type.
122+
// This overrides the instance type set with `kola run`
123+
InstanceType string
120124
}
121125

122126
// Registered tests that run as part of `kola run` live here. Mapping of names

mantle/platform/api/azure/instance.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (a *API) getInstance(name, resourceGroup string) (armcompute.VirtualMachine
5151
return resp.VirtualMachine, nil
5252
}
5353

54-
func (a *API) getVMParameters(name, userdata, sshkey, storageAccountURI string, ip armnetwork.PublicIPAddress, nic armnetwork.Interface) armcompute.VirtualMachine {
54+
func (a *API) getVMParameters(name, userdata, sshkey, storageAccountURI, size string, ip armnetwork.PublicIPAddress, nic armnetwork.Interface) armcompute.VirtualMachine {
5555

5656
// Azure requires that either a username/password be set or an SSH key.
5757
//
@@ -125,7 +125,7 @@ func (a *API) getVMParameters(name, userdata, sshkey, storageAccountURI string,
125125
},
126126
Properties: &armcompute.VirtualMachineProperties{
127127
HardwareProfile: &armcompute.HardwareProfile{
128-
VMSize: to.Ptr(armcompute.VirtualMachineSizeTypes(a.opts.Size)),
128+
VMSize: to.Ptr(armcompute.VirtualMachineSizeTypes(size)),
129129
},
130130
StorageProfile: &armcompute.StorageProfile{
131131
ImageReference: imgRef,
@@ -181,7 +181,14 @@ func (a *API) CreateInstance(name, userdata, sshkey, resourceGroup, storageAccou
181181
return nil, fmt.Errorf("couldn't get NIC name")
182182
}
183183

184-
vmParams := a.getVMParameters(name, userdata, sshkey, fmt.Sprintf("https://%s.blob.core.windows.net/", storageAccount), ip, nic)
184+
var size string
185+
if opts.InstanceType != "" {
186+
size = opts.InstanceType
187+
} else {
188+
size = a.opts.Size
189+
}
190+
191+
vmParams := a.getVMParameters(name, userdata, sshkey, fmt.Sprintf("https://%s.blob.core.windows.net/", storageAccount), size, ip, nic)
185192

186193
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
187194
defer cancel()

mantle/platform/machine/aws/cluster.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func (ac *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
5757
return nil, errors.New("platform aws does not support appending firstboot kernel arguments")
5858
}
5959

60+
if options.InstanceType != "" {
61+
return nil, errors.New("platform aws does not support changing instance types")
62+
}
63+
6064
conf, err := ac.RenderUserData(userdata, map[string]string{
6165
"$public_ipv4": "${COREOS_EC2_IPV4_PUBLIC}",
6266
"$private_ipv4": "${COREOS_EC2_IPV4_LOCAL}",

mantle/platform/machine/do/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func (dc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
5252
if options.AppendFirstbootKernelArgs != "" {
5353
return nil, errors.New("platform do does not support appending firstboot kernel arguments")
5454
}
55+
if options.InstanceType != "" {
56+
return nil, errors.New("platform do does not support changing instance types")
57+
}
5558

5659
conf, err := dc.RenderUserData(userdata, map[string]string{
5760
"$public_ipv4": "${COREOS_DIGITALOCEAN_IPV4_PUBLIC_0}",

mantle/platform/machine/esx/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func (ec *cluster) NewMachineWithOptions(userdata *platformConf.UserData, option
5858
if options.AppendFirstbootKernelArgs != "" {
5959
return nil, errors.New("platform esx does not support appending firstboot kernel arguments")
6060
}
61+
if options.InstanceType != "" {
62+
return nil, errors.New("platform esx does not support changing instance types")
63+
}
6164

6265
conf, err := ec.RenderUserData(userdata, map[string]string{
6366
"$public_ipv4": "${COREOS_ESX_IPV4_PUBLIC_0}",

mantle/platform/machine/gcloud/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ func (gc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
4949
if options.AppendFirstbootKernelArgs != "" {
5050
return nil, errors.New("platform gcp does not support appending firstboot kernel arguments")
5151
}
52+
if options.InstanceType != "" {
53+
return nil, errors.New("platform gcp does not support changing instance types")
54+
}
5255

5356
conf, err := gc.RenderUserData(userdata, map[string]string{
5457
"$public_ipv4": "${COREOS_GCE_IP_EXTERNAL_0}",

mantle/platform/machine/openstack/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func (oc *cluster) NewMachineWithOptions(userdata *conf.UserData, options platfo
5050
if options.AppendFirstbootKernelArgs != "" {
5151
return nil, errors.New("platform openstack does not support appending firstboot kernel arguments")
5252
}
53+
if options.InstanceType != "" {
54+
return nil, errors.New("platform openstack does not support changing instance types")
55+
}
5356

5457
conf, err := oc.RenderUserData(userdata, map[string]string{
5558
"$public_ipv4": "${COREOS_OPENSTACK_IPV4_PUBLIC}",

mantle/platform/machine/qemu/cluster.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ func (qc *Cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
4949
}
5050

5151
func (qc *Cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
52+
if options.InstanceType != "" {
53+
return nil, errors.New("platform qemu does not support changing instance types")
54+
}
5255
return qc.NewMachineWithQemuOptions(userdata, platform.QemuMachineOptions{
5356
MachineOptions: options,
5457
})

mantle/platform/machine/qemuiso/cluster.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ func (qc *Cluster) NewMachine(userdata *conf.UserData) (platform.Machine, error)
4747
}
4848

4949
func (qc *Cluster) NewMachineWithOptions(userdata *conf.UserData, options platform.MachineOptions) (platform.Machine, error) {
50+
if options.InstanceType != "" {
51+
return nil, errors.New("platform qemu-iso does not support changing instance types")
52+
}
53+
if options.MultiPathDisk {
54+
return nil, errors.New("platform qemu-iso does not support multipathed primary disks")
55+
}
5056
return qc.NewMachineWithQemuOptions(userdata, platform.QemuMachineOptions{
5157
MachineOptions: options,
5258
})
5359
}
5460

5561
func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options platform.QemuMachineOptions) (platform.Machine, error) {
56-
if options.MultiPathDisk {
57-
return nil, errors.New("platform qemu-iso does not support multipathed primary disks")
58-
}
5962
id := uuid.New()
6063

6164
dir := filepath.Join(qc.RuntimeConf().OutputDir, id)

mantle/platform/platform.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ type MachineOptions struct {
163163
AppendKernelArgs string
164164
AppendFirstbootKernelArgs string
165165
SkipStartMachine bool // Skip platform.StartMachine on machine bringup
166+
InstanceType string
166167
}
167168

168169
// SystemdDropin is a userdata type agnostic struct representing a systemd dropin

0 commit comments

Comments
 (0)