Skip to content

Commit 40707f4

Browse files
committed
kola: add support for primaryDisk key
Just like we have `additionalDisks`, add a new `primaryDisk` key which takes the same "diskspec" format. This immediately unlocks all the same knobs available to additional disks to the primary disk itself from external tests. E.g. with this, we can now migrate multipath tests to external tests that use `primaryDisk: 20G:mpath`. My immediate motivation for this however is to be able to use the new `512e` disk option from an external test as part of fixing OCPBUGS-35410.
1 parent db259de commit 40707f4

File tree

5 files changed

+34
-24
lines changed

5 files changed

+34
-24
lines changed

docs/kola/external-tests.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ Here's an example `kola.json`:
191191
"platforms": "qemu",
192192
"tags": "sometagname needs-internet skip-base-checks othertag",
193193
"requiredTag": "special",
194+
"primaryDisk": ["20G:mpath"],
194195
"additionalDisks": [ "5G" ],
195196
"minMemory": 4096,
196197
"minDisk": 15,
@@ -229,7 +230,8 @@ If a test has a `requiredTag`, it is run only if the required tag is specified.
229230
In the example above, the test would only run if `--tag special` was provided.
230231

231232
The `additionalDisks` key has the same semantics as the `--add-disk` argument
232-
to `qemuexec`. It is currently only supported on `qemu`.
233+
to `qemuexec`. It is currently only supported on `qemu`. The `primaryDisk` key
234+
also supports the same syntax and controls the primary boot disk.
233235

234236
The `injectContainer` boolean if set will cause the framework to inject
235237
the ostree base image container into the target system; the path can be

mantle/kola/harness.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ type externalTestMeta struct {
10201020
Tags string `json:"tags,omitempty" yaml:"tags,omitempty"`
10211021
RequiredTag string `json:"requiredTag,omitempty" yaml:"requiredTag,omitempty"`
10221022
AdditionalDisks []string `json:"additionalDisks,omitempty" yaml:"additionalDisks,omitempty"`
1023+
PrimaryDisk string `json:"primaryDisk,omitempty" yaml:"primaryDisk,omitempty"`
10231024
InjectContainer bool `json:"injectContainer,omitempty" yaml:"injectContainer,omitempty"`
10241025
MinMemory int `json:"minMemory,omitempty" yaml:"minMemory,omitempty"`
10251026
MinDiskSize int `json:"minDisk,omitempty" yaml:"minDisk,omitempty"`
@@ -1233,6 +1234,7 @@ ExecStart=%s
12331234
Tags: []string{"external"},
12341235

12351236
AdditionalDisks: targetMeta.AdditionalDisks,
1237+
PrimaryDisk: targetMeta.PrimaryDisk,
12361238
InjectContainer: targetMeta.InjectContainer,
12371239
MinMemory: targetMeta.MinMemory,
12381240
MinDiskSize: targetMeta.MinDiskSize,
@@ -1752,6 +1754,7 @@ func runTest(h *harness.H, t *register.Test, pltfrm string, flight platform.Flig
17521754

17531755
options := platform.MachineOptions{
17541756
MultiPathDisk: t.MultiPathDisk,
1757+
PrimaryDisk: t.PrimaryDisk,
17551758
AdditionalDisks: t.AdditionalDisks,
17561759
MinMemory: t.MinMemory,
17571760
MinDiskSize: t.MinDiskSize,

mantle/kola/register/register.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,26 @@ type Test struct {
7070
RequiredTag string // if specified, test is filtered by default unless tag is provided -- defaults to none
7171
Description string // test description
7272

73-
// Whether the primary disk is multipathed.
73+
// Whether the primary disk is multipathed. Deprecated in favour of PrimaryDisk.
7474
MultiPathDisk bool
7575

7676
// Sizes of additional empty disks to attach to the node, followed by
7777
// comma-separated list of optional options (e.g. ["1G",
7878
// "5G:mpath,foo,bar"]) -- defaults to none.
7979
AdditionalDisks []string
8080

81+
// Size of primary disk to attach to the node, followed by
82+
// comma-separated list of optional options (e.g. "20G:mpath"]).
83+
PrimaryDisk string
84+
8185
// InjectContainer will cause the ostree base image to be injected into the target
8286
InjectContainer bool
8387

8488
// Minimum amount of memory in MB required for test.
8589
MinMemory int
8690

87-
// Minimum amount of primary disk in GB required for test.
91+
// Minimum amount of primary disk in GB required for test. Deprecated in favour
92+
// of PrimaryDisk.
8893
MinDiskSize int
8994

9095
// Additional amount of NICs required for test.

mantle/platform/machine/qemu/cluster.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -140,34 +140,33 @@ func (qc *Cluster) NewMachineWithQemuOptions(userdata *conf.UserData, options pl
140140
builder.MemoryMiB = 4096 // SE needs at least 4GB
141141
}
142142

143-
channel := "virtio"
143+
var primaryDisk platform.Disk
144+
if options.PrimaryDisk != "" {
145+
var diskp *platform.Disk
146+
if diskp, err = platform.ParseDisk(options.PrimaryDisk); err != nil {
147+
return nil, errors.Wrapf(err, "parsing primary disk spec '%s'", options.PrimaryDisk)
148+
}
149+
primaryDisk = *diskp
150+
}
151+
144152
if qc.flight.opts.Nvme || options.Nvme {
145-
channel = "nvme"
153+
primaryDisk.Channel = "nvme"
146154
}
147-
sectorSize := 0
148-
logicalSectorSize := 0
149155
if qc.flight.opts.Native4k {
150-
sectorSize = 4096
156+
primaryDisk.SectorSize = 4096
151157
} else if qc.flight.opts.Disk512e {
152-
sectorSize = 4096
153-
logicalSectorSize = 512
158+
primaryDisk.SectorSize = 4096
159+
primaryDisk.LogicalSectorSize = 512
154160
}
155-
multiPathDisk := options.MultiPathDisk || qc.flight.opts.MultiPathDisk
156-
var diskSize string
157-
if options.MinDiskSize > 0 {
158-
diskSize = fmt.Sprintf("%dG", options.MinDiskSize)
159-
} else {
160-
diskSize = qc.flight.opts.DiskSize
161+
if options.MultiPathDisk || qc.flight.opts.MultiPathDisk {
162+
primaryDisk.MultiPathDisk = true
161163
}
162-
primaryDisk := platform.Disk{
163-
BackingFile: qc.flight.opts.DiskImage,
164-
Channel: channel,
165-
Size: diskSize,
166-
SectorSize: sectorSize,
167-
LogicalSectorSize: logicalSectorSize,
168-
MultiPathDisk: multiPathDisk,
164+
if options.MinDiskSize > 0 {
165+
primaryDisk.Size = fmt.Sprintf("%dG", options.MinDiskSize)
166+
} else if qc.flight.opts.DiskSize != "" {
167+
primaryDisk.Size = qc.flight.opts.DiskSize
169168
}
170-
169+
primaryDisk.BackingFile = qc.flight.opts.DiskImage
171170
if options.OverrideBackingFile != "" {
172171
primaryDisk.BackingFile = options.OverrideBackingFile
173172
}

mantle/platform/platform.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ type Flight interface {
155155

156156
type MachineOptions struct {
157157
MultiPathDisk bool
158+
PrimaryDisk string
158159
AdditionalDisks []string
159160
MinMemory int
160161
MinDiskSize int

0 commit comments

Comments
 (0)