Skip to content

Commit 0eb6a8f

Browse files
committed
Default to Gen2 images for OpenShift 4.20+ with fallback to Gen1
From 4.20 onwards, clusters will be deployed with V2 images. If the selected SKU doesn't support it, then fallback to using V1 image. Fixes ARO-23073 Signed-off-by: Yadnesh Kulkarni <ykulkarn@redhat.com>
1 parent 92dda0a commit 0eb6a8f

2 files changed

Lines changed: 16 additions & 18 deletions

File tree

pkg/installer/generateconfig.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,21 +165,20 @@ func (m *manager) generateInstallConfig(ctx context.Context) (*installconfig.Ins
165165
// from a manifest so it can be specified in the RP's
166166
// OpenShiftClusterVersions?
167167

168-
imageSKU := "aro_420" // Gen1 SKU (default)
168+
// 4.20 onwards, we default to Gen2 images
169+
imageSKU := "aro_420-v2" // Gen2 SKU (default)
169170

170-
// Check if any SKU requires V2 only (doesn't support V1)
171-
masterRequiresV2, err := determineSkuSupportsV2Only(masterSKU)
171+
// If any SKU doesn't support V2, use Gen1 images
172+
masterSupportsV2, err := determineV2SkuSupport(masterSKU)
172173
if err != nil {
173174
return nil, nil, errors.WithStack(err)
174175
}
175-
workerRequiresV2, err := determineSkuSupportsV2Only(workerSKU)
176+
workerSupportsV2, err := determineV2SkuSupport(workerSKU)
176177
if err != nil {
177178
return nil, nil, errors.WithStack(err)
178179
}
179-
180-
// If any SKU only supports V2, use Gen2 images for the entire cluster.
181-
if masterRequiresV2 || workerRequiresV2 {
182-
imageSKU = "aro_420-v2"
180+
if !masterSupportsV2 || !workerSupportsV2 {
181+
imageSKU = "aro_420"
183182
}
184183

185184
rhcosImage := &azuretypes.OSImage{
@@ -475,9 +474,8 @@ func determineAvailabilityZones(controlPlaneSKU, workerSKU *mgmtcompute.Resource
475474
return controlPlaneZones, workerZones, nil
476475
}
477476

478-
// determineSkuSupportsV2Only checks if the SKU ONLY supports HyperV Generation V2 (not V1).
479-
// Returns true if the SKU requires Gen2 images (supports V2 but not V1).
480-
func determineSkuSupportsV2Only(sku *mgmtcompute.ResourceSku) (bool, error) {
477+
// determineV2SkuSupport returns true if the SKU supports HyperV Generation V2
478+
func determineV2SkuSupport(sku *mgmtcompute.ResourceSku) (bool, error) {
481479
skuCapabilities, capabilityExists := computeskus.GetCapabilityMap(sku)
482480
if !capabilityExists {
483481
return false, fmt.Errorf("no capabilities found for SKU %s", *sku.Name)
@@ -486,5 +484,5 @@ func determineSkuSupportsV2Only(sku *mgmtcompute.ResourceSku) (bool, error) {
486484
if err != nil {
487485
return false, fmt.Errorf("could not fetch HyperV generations for SKU %s: %w", *sku.Name, err)
488486
}
489-
return generations.Has("V2") && !generations.Has("V1"), nil
487+
return generations.Has("V2"), nil
490488
}

pkg/installer/generateconfig_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,25 +50,25 @@ func TestVMNetworkingType(t *testing.T) {
5050
}
5151
}
5252

53-
func TestDetermineSkuSupportsV2Only(t *testing.T) {
53+
func TestDetermineV2SkuSupport(t *testing.T) {
5454
for _, tt := range []struct {
5555
name string
5656
sku *mgmtcompute.ResourceSku
5757
wantResult bool
5858
wantErr string
5959
}{
6060
{
61-
name: "sku supports both V1 and V2, does not require V2",
61+
name: "sku supports both V1 and V2",
6262
sku: &mgmtcompute.ResourceSku{
6363
Name: to.StringPtr("Standard_D8s_v3"),
6464
Capabilities: &[]mgmtcompute.ResourceSkuCapabilities{
6565
{Name: to.StringPtr("HyperVGenerations"), Value: to.StringPtr("V1,V2")},
6666
},
6767
},
68-
wantResult: false,
68+
wantResult: true,
6969
},
7070
{
71-
name: "sku supports only V2, requires V2",
71+
name: "sku supports only V2",
7272
sku: &mgmtcompute.ResourceSku{
7373
Name: to.StringPtr("Standard_D8s_v6"),
7474
Capabilities: &[]mgmtcompute.ResourceSkuCapabilities{
@@ -78,7 +78,7 @@ func TestDetermineSkuSupportsV2Only(t *testing.T) {
7878
wantResult: true,
7979
},
8080
{
81-
name: "sku supports only V1, does not require V2",
81+
name: "sku supports only V1",
8282
sku: &mgmtcompute.ResourceSku{
8383
Name: to.StringPtr("Standard_D2_v2"),
8484
Capabilities: &[]mgmtcompute.ResourceSkuCapabilities{
@@ -108,7 +108,7 @@ func TestDetermineSkuSupportsV2Only(t *testing.T) {
108108
},
109109
} {
110110
t.Run(tt.name, func(t *testing.T) {
111-
result, err := determineSkuSupportsV2Only(tt.sku)
111+
result, err := determineV2SkuSupport(tt.sku)
112112

113113
if tt.wantErr != "" {
114114
if err == nil {

0 commit comments

Comments
 (0)