Skip to content

Commit 97030df

Browse files
Merge pull request #9836 from sadasu/fix-sno-installs
OCPBUGS-59220: Refine check for supported SNO platforms to include IBMCloud
2 parents 184b556 + 1a80cb7 commit 97030df

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

pkg/asset/machines/master.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (m *Master) Generate(ctx context.Context, dependencies asset.Parents) error
189189
// Check if SNO topology is supported on this platform
190190
if pool.Replicas != nil && *pool.Replicas == 1 {
191191
bootstrapInPlace := false
192-
if ic.BootstrapInPlace != nil {
192+
if ic.BootstrapInPlace != nil && ic.BootstrapInPlace.InstallationDisk != "" {
193193
bootstrapInPlace = true
194194
}
195195
if !supportedSingleNodePlatform(bootstrapInPlace, ic.Platform.Name()) {
@@ -985,7 +985,7 @@ func IsFencingCredentialsFile(filepath string) (bool, error) {
985985
// a platform.
986986
func supportedSingleNodePlatform(bootstrapInPlace bool, platformName string) bool {
987987
switch platformName {
988-
case awstypes.Name, gcptypes.Name, azuretypes.Name, powervstypes.Name, nonetypes.Name:
988+
case awstypes.Name, gcptypes.Name, azuretypes.Name, powervstypes.Name, nonetypes.Name, ibmcloudtypes.Name:
989989
// Single node OpenShift installations supported without `bootstrapInPlace`
990990
return true
991991
case externaltypes.Name:

pkg/asset/machines/master_test.go

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ import (
2121
"github.com/openshift/installer/pkg/types"
2222
awstypes "github.com/openshift/installer/pkg/types/aws"
2323
"github.com/openshift/installer/pkg/types/baremetal"
24+
"github.com/openshift/installer/pkg/types/external"
25+
ibmcloudtypes "github.com/openshift/installer/pkg/types/ibmcloud"
2426
"github.com/openshift/installer/pkg/types/none"
27+
"github.com/openshift/installer/pkg/types/nutanix"
2528
)
2629

2730
func TestMasterGenerateMachineConfigs(t *testing.T) {
@@ -453,3 +456,135 @@ func TestFencingCredentialsSecretsFile(t *testing.T) {
453456
})
454457
}
455458
}
459+
460+
func TestSupportedSNOPlatforms(t *testing.T) {
461+
cases := []struct {
462+
name string
463+
platform types.Platform
464+
bootstrapInPlace *types.BootstrapInPlace
465+
machinePoolPlatform types.MachinePoolPlatform
466+
expectedError bool
467+
}{
468+
{
469+
name: "AWS platform",
470+
platform: types.Platform{
471+
AWS: &awstypes.Platform{
472+
Region: "us-east-1",
473+
DefaultMachinePlatform: &awstypes.MachinePool{
474+
InstanceType: "TEST_INSTANCE_TYPE",
475+
},
476+
},
477+
},
478+
bootstrapInPlace: &types.BootstrapInPlace{},
479+
machinePoolPlatform: types.MachinePoolPlatform{
480+
AWS: &awstypes.MachinePool{
481+
Zones: []string{"us-east-1a"},
482+
},
483+
},
484+
expectedError: false,
485+
},
486+
{
487+
name: "None platform",
488+
platform: types.Platform{
489+
None: &none.Platform{},
490+
},
491+
machinePoolPlatform: types.MachinePoolPlatform{},
492+
expectedError: false,
493+
},
494+
{
495+
name: "IBMCloud platform",
496+
platform: types.Platform{
497+
IBMCloud: &ibmcloudtypes.Platform{},
498+
},
499+
bootstrapInPlace: &types.BootstrapInPlace{},
500+
machinePoolPlatform: types.MachinePoolPlatform{
501+
IBMCloud: &ibmcloudtypes.MachinePool{
502+
Zones: []string{"us-east-1"},
503+
},
504+
},
505+
expectedError: false,
506+
},
507+
{
508+
name: "External platform with bootstrapInPlace",
509+
platform: types.Platform{
510+
External: &external.Platform{},
511+
},
512+
bootstrapInPlace: &types.BootstrapInPlace{
513+
InstallationDisk: "/dev/nvme0n1",
514+
},
515+
machinePoolPlatform: types.MachinePoolPlatform{},
516+
expectedError: false,
517+
},
518+
{
519+
name: "External platform with empty bootstrapInPlace",
520+
platform: types.Platform{
521+
External: &external.Platform{},
522+
},
523+
bootstrapInPlace: &types.BootstrapInPlace{},
524+
machinePoolPlatform: types.MachinePoolPlatform{},
525+
expectedError: true,
526+
},
527+
{
528+
name: "External platform without bootstrapInPlace",
529+
platform: types.Platform{
530+
External: &external.Platform{},
531+
},
532+
machinePoolPlatform: types.MachinePoolPlatform{},
533+
expectedError: true,
534+
},
535+
{
536+
name: "Nutanix platform",
537+
platform: types.Platform{
538+
Nutanix: &nutanix.Platform{},
539+
},
540+
machinePoolPlatform: types.MachinePoolPlatform{},
541+
expectedError: true,
542+
},
543+
}
544+
for _, tc := range cases {
545+
t.Run(tc.name, func(t *testing.T) {
546+
parents := asset.Parents{}
547+
parents.Add(
548+
&installconfig.ClusterID{
549+
UUID: "test-uuid",
550+
InfraID: "test-infra-id",
551+
},
552+
installconfig.MakeAsset(
553+
&types.InstallConfig{
554+
ObjectMeta: metav1.ObjectMeta{
555+
Name: "test-cluster",
556+
},
557+
SSHKey: "ssh-rsa: dummy-key",
558+
BaseDomain: "test-domain",
559+
Platform: tc.platform,
560+
ControlPlane: &types.MachinePool{
561+
Hyperthreading: types.HyperthreadingEnabled,
562+
Replicas: ptr.To[int64](1),
563+
Platform: tc.machinePoolPlatform,
564+
},
565+
BootstrapInPlace: tc.bootstrapInPlace,
566+
}),
567+
568+
rhcos.MakeAsset("test-image"),
569+
(*rhcos.Release)(ptr.To[string]("412.86.202208101040-0")),
570+
&machine.Master{
571+
File: &asset.File{
572+
Filename: "master-ignition",
573+
Data: []byte("test-ignition"),
574+
},
575+
},
576+
)
577+
snoErrorRegex := fmt.Sprintf("this install method does not support Single Node installation on platform %s", tc.platform.Name())
578+
master := &Master{}
579+
err := master.Generate(context.Background(), parents)
580+
if tc.expectedError {
581+
if assert.Error(t, err) {
582+
assert.Regexp(t, snoErrorRegex, err.Error())
583+
}
584+
} else if err != nil {
585+
// Did not expect a SNO validation error but received a different error
586+
assert.NotRegexp(t, snoErrorRegex, err.Error())
587+
}
588+
})
589+
}
590+
}

0 commit comments

Comments
 (0)