Skip to content
Closed
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
7 changes: 6 additions & 1 deletion cmd/nodecmd/create_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,14 @@ func getGCPConfig(singleNode bool) (*gcpAPI.GcpCloud, map[string]NumNodes, strin
return nil, nil, "", "", "", err
}
finalZones := map[string]NumNodes{}

gcpRegions, err := gcpCloud.ListRegions()
if err != nil {
return nil, nil, "", "", "", err
}
// verify regions are valid and place in random zones per region
for region, numNodes := range finalRegions {
if !slices.Contains(gcpCloud.ListRegions(), region) {
if !slices.Contains(gcpRegions, region) {
return nil, nil, "", "", "", fmt.Errorf("invalid region %s", region)
} else {
finalZone, err := gcpCloud.GetRandomZone(region)
Expand Down
6 changes: 3 additions & 3 deletions pkg/cloud/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,17 +457,17 @@ func (c *GcpCloud) AddFirewall(publicIP, networkName, projectName, firewallName
}

// ListRegions returns a list of regions for the GcpCloud instance.
func (c *GcpCloud) ListRegions() []string {
func (c *GcpCloud) ListRegions() ([]string, error) {
regionListCall := c.gcpClient.Regions.List(c.projectID)
regionList, err := regionListCall.Do()
if err != nil {
return nil
return nil, err
}
regions := []string{}
for _, region := range regionList.Items {
regions = append(regions, region.Name)
}
return regions
return regions, nil
}

// ListZonesInRegion returns a list of zones in a specific region for a given project ID.
Expand Down