Skip to content

Commit 1353744

Browse files
committed
PowerVS: Fix VPC subnets
The cluster-api-provider-ibmcloud uses a fixed set of subnets per VPC. So, until we can ask the provider what it is, bring that data in so we can use it.
1 parent cd01bd5 commit 1353744

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

pkg/asset/manifests/cloudproviderconfig.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,18 @@ func (cpc *CloudProviderConfig) Generate(dependencies asset.Parents) error {
257257

258258
if len(vpcSubnets) == 0 {
259259
if capiutils.IsEnabled(installConfig) {
260+
vpcZones, err := powervstypes.AvailableVPCZones(installConfig.Config.PowerVS.Region)
261+
if err != nil {
262+
return err
263+
}
264+
260265
// The PowerVS CAPI provider generates three subnets. One for
261266
// each of the endpoint.
262267
// @TODO the provider should export a function which gives us
263268
// an array
264-
for i := 1; i <= 3; i++ {
269+
for _, zone := range vpcZones {
265270
vpcSubnets = append(vpcSubnets,
266-
fmt.Sprintf("%s-vpcsubnet-%s-%d",
267-
clusterID.InfraID,
268-
vpcRegion,
269-
i))
271+
fmt.Sprintf("%s-vpcsubnet-%s", clusterID.InfraID, zone))
270272
}
271273
} else {
272274
vpcSubnets = append(vpcSubnets, fmt.Sprintf("vpc-subnet-%s", clusterID.InfraID))

pkg/types/powervs/powervs_regions.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Region struct {
1717
COSRegion string
1818
Zones []string
1919
SysTypes []string
20+
VPCZones []string
2021
}
2122

2223
// Regions holds the regions for IBM Power VS, and descriptions used during the survey.
@@ -27,34 +28,39 @@ var Regions = map[string]Region{
2728
COSRegion: "us-south",
2829
Zones: []string{"dal10", "dal12"},
2930
SysTypes: []string{"s922", "e980"},
31+
VPCZones: []string{"us-south-1", "us-south-2", "us-south-3"},
3032
},
3133
"eu-de": {
3234
Description: "Frankfurt, Germany",
3335
VPCRegion: "eu-de",
3436
COSRegion: "eu-de",
3537
Zones: []string{"eu-de-1", "eu-de-2"},
3638
SysTypes: []string{"s922", "e980"},
39+
VPCZones: []string{"eu-de-2", "eu-de-3"},
3740
},
3841
"mad": {
3942
Description: "Madrid, Spain",
4043
VPCRegion: "eu-es",
4144
COSRegion: "eu-de", // @HACK - PowerVS says COS not supported in this region
4245
Zones: []string{"mad02", "mad04"},
4346
SysTypes: []string{"s1022"},
47+
VPCZones: []string{"eu-es-1", "eu-es-2"},
4448
},
4549
"sao": {
4650
Description: "São Paulo, Brazil",
4751
VPCRegion: "br-sao",
4852
COSRegion: "br-sao",
4953
Zones: []string{"sao04"},
5054
SysTypes: []string{"s922", "e980"},
55+
VPCZones: []string{"br-sao-1", "br-sao-2"},
5156
},
5257
"wdc": {
5358
Description: "Washington DC, USA",
5459
VPCRegion: "us-east",
5560
COSRegion: "us-east",
5661
Zones: []string{"wdc06", "wdc07"},
5762
SysTypes: []string{"s922", "e980"},
63+
VPCZones: []string{"us-east-1", "us-east-2", "us-east-3"},
5864
},
5965
}
6066

@@ -143,6 +149,15 @@ func AllKnownSysTypes() sets.Set[string] {
143149
return sysTypes
144150
}
145151

152+
// AvailableVPCZones returns the known VPC zones for a specified region.
153+
func AvailableVPCZones(region string) ([]string, error) {
154+
knownRegion, ok := Regions[region]
155+
if !ok {
156+
return nil, fmt.Errorf("unknown region name provided")
157+
}
158+
return knownRegion.VPCZones, nil
159+
}
160+
146161
// COSRegionForVPCRegion returns the corresponding COS region for the given VPC region.
147162
func COSRegionForVPCRegion(vpcRegion string) (string, error) {
148163
for r := range Regions {

0 commit comments

Comments
 (0)