Skip to content

Commit b6ffbc0

Browse files
committed
OCPBUGS-27737: aws-edge-zones: preventing errors when discovering phase
AWS Wavelength Zones have been introduced as part of edge-zones in 4.15. The function used to discover the valid edge zones in the region is prematurely returning errors when the region haven't available any of Local Zones or Wavelength Zones, which could cause issues in regions which support only one edge zone type. https://issues.redhat.com//browse/OCPBUGS-27737
1 parent 225c5f7 commit b6ffbc0

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pkg/asset/installconfig/aws/availabilityzones.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func describeAvailabilityZones(ctx context.Context, session *session.Session, re
7171

7272
// filterZonesByType retrieves a list of zones by a given ZoneType attribute within the region.
7373
// ZoneType can be availability-zone, local-zone or wavelength-zone.
74-
func filterZonesByType(ctx context.Context, session *session.Session, region string, zoneType string) ([]string, error) {
74+
func filterZonesByType(ctx context.Context, session *session.Session, region, zoneType string) ([]string, error) {
7575
azs, err := describeAvailabilityZones(ctx, session, region, []string{})
7676
if err != nil {
7777
return nil, fmt.Errorf("fetching %s: %w", zoneType, err)
@@ -83,16 +83,19 @@ func filterZonesByType(ctx context.Context, session *session.Session, region str
8383
}
8484
}
8585

86-
if len(zones) == 0 {
87-
return nil, fmt.Errorf("no zones with type %s in %s", zoneType, region)
88-
}
89-
9086
return zones, nil
9187
}
9288

9389
// availabilityZones retrieves a list of zones type 'availability-zone' in the region.
9490
func availabilityZones(ctx context.Context, session *session.Session, region string) ([]string, error) {
95-
return filterZonesByType(ctx, session, region, typesaws.AvailabilityZoneType)
91+
zones, err := filterZonesByType(ctx, session, region, typesaws.AvailabilityZoneType)
92+
if err != nil {
93+
return nil, err
94+
}
95+
if len(zones) == 0 {
96+
return nil, fmt.Errorf("no zones with type availability-zone in %s", region)
97+
}
98+
return zones, nil
9699
}
97100

98101
// edgeZones retrieves a list of zones type 'local-zone' and 'wavelength-zone' in the region.
@@ -110,6 +113,10 @@ func edgeZones(ctx context.Context, session *session.Session, region string) ([]
110113
edgeZones = append(edgeZones, localZones...)
111114
edgeZones = append(edgeZones, wavelengthZones...)
112115

116+
if len(edgeZones) == 0 {
117+
return nil, fmt.Errorf("unable to find zone types with local-zone or wavelength-zone in the region %s", region)
118+
}
119+
113120
return edgeZones, nil
114121
}
115122

0 commit comments

Comments
 (0)