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

[rhcos-4.17] mantle/gcp: support c3 metal instance types #3882

Merged
merged 1 commit into from
Sep 13, 2024
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
14 changes: 13 additions & 1 deletion mantle/cmd/kola/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func init() {
sv(&kola.GCPOptions.Project, "gcp-project", "fedora-coreos-devel", "GCP project name")
sv(&kola.GCPOptions.Zone, "gcp-zone", "us-central1-a", "GCP zone name")
sv(&kola.GCPOptions.MachineType, "gcp-machinetype", "", "GCP machine type")
sv(&kola.GCPOptions.DiskType, "gcp-disktype", "pd-ssd", "GCP disk type")
sv(&kola.GCPOptions.DiskType, "gcp-disktype", "", "GCP disk type (default pd-ssd)")
sv(&kola.GCPOptions.Network, "gcp-network", "default", "GCP network")
sv(&kola.GCPOptions.ServiceAcct, "gcp-service-account", "", "GCP service account to attach to instance (default project default)")
bv(&kola.GCPOptions.ServiceAuth, "gcp-service-auth", false, "for non-interactive auth when running within GCP")
Expand Down Expand Up @@ -257,6 +257,18 @@ func syncOptionsImpl(useCosa bool) error {
}
fmt.Printf("Using %s instance type\n", kola.GCPOptions.MachineType)
}
// Set the disktype for gcp based on the instance type. metal
// instances require hyperdisk storage, all other should be able
// to use pd-ssd.
// https://cloud.google.com/compute/docs/general-purpose-machines#c3_disks
if kolaPlatform == "gcp" && kola.GCPOptions.DiskType == "" {
if strings.HasSuffix(kola.GCPOptions.MachineType, "metal") {
kola.GCPOptions.DiskType = "hyperdisk-balanced"
} else {
kola.GCPOptions.DiskType = "pd-ssd"
}
fmt.Printf("Using %s disktype for gcp instance\n", kola.GCPOptions.DiskType)
}

// if no external dirs were given, automatically add the working directory;
// does nothing if ./tests/kola/ doesn't exist
Expand Down
6 changes: 6 additions & 0 deletions mantle/platform/api/gcloud/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ func (a *API) mkinstance(userdata, name string, keys []*agent.Key, opts platform
OnHostMaintenance: "TERMINATE",
}
}
// metal instances can only have a TERMINATE maintenance policy
if strings.HasSuffix(a.options.MachineType, "metal") {
instance.Scheduling = &compute.Scheduling{
OnHostMaintenance: "TERMINATE",
}
}
// attach aditional disk
for _, spec := range opts.AdditionalDisks {
plog.Debugf("Parsing disk spec %q\n", spec)
Expand Down
5 changes: 5 additions & 0 deletions mantle/platform/api/gcloud/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func (a *API) CreateImage(spec *ImageSpec, overwrite bool) (*compute.Operation,
}
}

// https://cloud.google.com/compute/docs/images/create-custom#guest-os-features
features := []*compute.GuestOsFeature{
// https://cloud.google.com/compute/docs/images/create-delete-deprecate-private-images
{
Expand All @@ -106,6 +107,10 @@ func (a *API) CreateImage(spec *ImageSpec, overwrite bool) (*compute.Operation,
{
Type: "SEV_SNP_CAPABLE",
},
// https://cloud.google.com/compute/docs/networking/using-idpf
{
Type: "IDPF",
},
}

if spec.Architecture == "" {
Expand Down
Loading