Skip to content

Commit b4e19a0

Browse files
Merge pull request #8219 from hamzy/PowerVS-fix-cos-region
no-jira: PowerVS: Fix COS region and VPC subnets
2 parents 6bb3cae + 1353744 commit b4e19a0

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
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/asset/manifests/powervs/cluster.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
2525
vpcRegion string
2626
transitGatewayName string
2727
cosName string
28+
cosRegion string
2829
imageName string
2930
bucketName string
3031
err error
@@ -40,6 +41,7 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
4041
logrus.Debugf("GenerateClusterAssets: vpcRegion = %v", vpcRegion)
4142
logrus.Debugf("GenerateClusterAssets: transitGatewayName = %v", transitGatewayName)
4243
logrus.Debugf("GenerateClusterAssets: cosName = %v", cosName)
44+
logrus.Debugf("GenerateClusterAssets: cosRegion = %v", cosRegion)
4345
logrus.Debugf("GenerateClusterAssets: imageName = %v", imageName)
4446
logrus.Debugf("GenerateClusterAssets: bucketName = %v", bucketName)
4547
logrus.Debugf("GenerateClusterAssets: powerVSCluster.Spec.ControlPlaneEndpoint.Host = %v", powerVSCluster.Spec.ControlPlaneEndpoint.Host)
@@ -77,6 +79,10 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
7779

7880
cosName = fmt.Sprintf("%s-cos", clusterID.InfraID)
7981

82+
if cosRegion, err = powervstypes.COSRegionForPowerVSRegion(installConfig.Config.PowerVS.Region); err != nil {
83+
return nil, fmt.Errorf("unable to derive cosRegion from region: %s %w", installConfig.Config.PowerVS.Region, err)
84+
}
85+
8086
imageName = fmt.Sprintf("rhcos-%s", clusterID.InfraID)
8187

8288
bucketName = fmt.Sprintf("%s-bootstrap-ign", clusterID.InfraID)
@@ -140,7 +146,7 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
140146
CosInstance: &capibm.CosInstance{
141147
Name: cosName,
142148
BucketName: bucketName,
143-
BucketRegion: vpcRegion,
149+
BucketRegion: cosRegion,
144150
},
145151
Ignition: &capibm.Ignition{
146152
Version: "3.4",
@@ -181,7 +187,7 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
181187
ServiceInstance: &service,
182188
Bucket: &bucket,
183189
Object: &object,
184-
Region: &vpcRegion,
190+
Region: &cosRegion,
185191
},
186192
}
187193

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)