Skip to content

Commit 93e6e82

Browse files
committed
mantle/gcp: support c3 metal instance types
This requires the IDPF guest OS feature flag to be set when creating GCP images and also a TERMINATE maintenance policy and hyperdisk storage. With this change, after uploading a disk you can then test with kola with something like: ``` cosa kola run -p=gcp \ --gcp-json-key=key.json \ --gcp-project=project \ --gcp-machinetype=c3-highcpu-192-metal \ --gcp-zone=us-central1-c basic ``` Related to coreos/fedora-coreos-tracker#1794
1 parent 51dc4ab commit 93e6e82

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

mantle/cmd/kola/options.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func init() {
120120
sv(&kola.GCPOptions.Project, "gcp-project", "fedora-coreos-devel", "GCP project name")
121121
sv(&kola.GCPOptions.Zone, "gcp-zone", "us-central1-a", "GCP zone name")
122122
sv(&kola.GCPOptions.MachineType, "gcp-machinetype", "", "GCP machine type")
123-
sv(&kola.GCPOptions.DiskType, "gcp-disktype", "pd-ssd", "GCP disk type")
123+
sv(&kola.GCPOptions.DiskType, "gcp-disktype", "", "GCP disk type (default pd-ssd)")
124124
sv(&kola.GCPOptions.Network, "gcp-network", "default", "GCP network")
125125
sv(&kola.GCPOptions.ServiceAcct, "gcp-service-account", "", "GCP service account to attach to instance (default project default)")
126126
bv(&kola.GCPOptions.ServiceAuth, "gcp-service-auth", false, "for non-interactive auth when running within GCP")
@@ -257,6 +257,18 @@ func syncOptionsImpl(useCosa bool) error {
257257
}
258258
fmt.Printf("Using %s instance type\n", kola.GCPOptions.MachineType)
259259
}
260+
// Set the disktype for gcp based on the instance type. metal
261+
// instances require hyperdisk storage, all other should be able
262+
// to use pd-ssd.
263+
// https://cloud.google.com/compute/docs/general-purpose-machines#c3_disks
264+
if kolaPlatform == "gcp" && kola.GCPOptions.DiskType == "" {
265+
if strings.HasSuffix(kola.GCPOptions.MachineType, "metal") {
266+
kola.GCPOptions.DiskType = "hyperdisk-balanced"
267+
} else {
268+
kola.GCPOptions.DiskType = "pd-ssd"
269+
}
270+
fmt.Printf("Using %s disktype for gcp instance\n", kola.GCPOptions.DiskType)
271+
}
260272

261273
// if no external dirs were given, automatically add the working directory;
262274
// does nothing if ./tests/kola/ doesn't exist

mantle/platform/api/gcloud/compute.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@ func (a *API) mkinstance(userdata, name string, keys []*agent.Key, opts platform
162162
return nil, fmt.Errorf("Does not support confidential type %s, should be: sev, sev_snp\n", a.options.ConfidentialType)
163163
}
164164
}
165+
// metal instances can only have a TERMINATE maintenance policy
166+
if strings.HasSuffix(a.options.MachineType, "metal") {
167+
instance.Scheduling = &compute.Scheduling{
168+
OnHostMaintenance: "TERMINATE",
169+
}
170+
}
165171
// attach aditional disk
166172
for _, spec := range opts.AdditionalDisks {
167173
plog.Debugf("Parsing disk spec %q\n", spec)

mantle/platform/api/gcloud/image.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ func (a *API) CreateImage(spec *ImageSpec, overwrite bool) (*compute.Operation,
8686
}
8787
}
8888

89+
// https://cloud.google.com/compute/docs/images/create-custom#guest-os-features
8990
features := []*compute.GuestOsFeature{
9091
// https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images
9192
{
@@ -106,6 +107,10 @@ func (a *API) CreateImage(spec *ImageSpec, overwrite bool) (*compute.Operation,
106107
{
107108
Type: "SEV_SNP_CAPABLE",
108109
},
110+
// https://cloud.google.com/compute/docs/networking/using-idpf
111+
{
112+
Type: "IDPF",
113+
},
109114
}
110115

111116
if spec.Architecture == "" {

0 commit comments

Comments
 (0)