Skip to content

Commit

Permalink
Merge #120555
Browse files Browse the repository at this point in the history
120555: roachprod: fix T2A validation r=srosenberg a=renatolabs

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

Co-authored-by: Renato Costa <[email protected]>
  • Loading branch information
craig[bot] and renatolabs committed Mar 18, 2024
2 parents 0b6de9c + 28a20c4 commit 4733c20
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pkg/roachprod/vm/gce/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"os"
"os/exec"
"regexp"
"slices"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -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, ","))
}
}
}
Expand Down

0 comments on commit 4733c20

Please sign in to comment.