From 28a20c4f73c84d84cc4e122d2eb0bf05fa8e89e3 Mon Sep 17 00:00:00 2001 From: Renato Costa Date: Fri, 15 Mar 2024 11:57:49 -0400 Subject: [PATCH] roachprod: fix T2A validation Roachprod tries to validate that the region we're a creating a cluster in is valid when creating ARM instances; that is because those are only available in certain GCE zones[^1]. The validation, however, was wrong when the user actually provided a `gce-zones` flag: it would try to verify that _every_ supported zone matched the one provided, which is obviously impossible. In this commit, we fix the validation logic and update the list of supported zones with the most recent data from the GCE documentation. [^1]: https://cloud.google.com/compute/docs/regions-zones#available Epic: none Release note: None --- pkg/roachprod/vm/gce/gcloud.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkg/roachprod/vm/gce/gcloud.go b/pkg/roachprod/vm/gce/gcloud.go index 273f03be1169..af8a2fe0d7a0 100644 --- a/pkg/roachprod/vm/gce/gcloud.go +++ b/pkg/roachprod/vm/gce/gcloud.go @@ -18,6 +18,7 @@ import ( "os" "os/exec" "regexp" + "slices" "sort" "strconv" "strings" @@ -1090,14 +1091,18 @@ func computeZones(opts vm.CreateOpts, providerOpts *ProviderOpts) ([]string, err if providerOpts.useArmAMI() { if len(providerOpts.Zones) == 0 { zones = []string{"us-central1-a"} - } else { - supportedT2ARegions := []string{"us-central1", "asia-southeast1", "europe-west4"} - for _, zone := range providerOpts.Zones { - for _, region := range supportedT2ARegions { - if !strings.HasPrefix(zone, region) { - return nil, errors.Newf("T2A instances are not supported outside of [%s]", strings.Join(supportedT2ARegions, ",")) - } - } + } + + // Extracted from https://cloud.google.com/compute/docs/regions-zones#available + supportedT2AZones := []string{ + "asia-southeast1-b", "asia-southeast1-c", + "europe-west4-a", "europe-west4-b", "europe-west4-c", + "us-central1-a", "us-central1-b", "us-central1-f", + } + + for _, zone := range providerOpts.Zones { + if slices.Index(supportedT2AZones, zone) == -1 { + return nil, errors.Newf("T2A instances are not supported outside of [%s]", strings.Join(supportedT2AZones, ",")) } } }