Skip to content

Commit

Permalink
NO-JIRA: Enable skip mco reboot functionality only if openshift versi…
Browse files Browse the repository at this point in the history
…on is 4.15 and higher
  • Loading branch information
ori-amizur committed Nov 9, 2023
1 parent 2d47e9a commit 6aaef89
Show file tree
Hide file tree
Showing 11 changed files with 92 additions and 24 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/featuresupport/feature_support_level.go
Expand Up @@ -16,6 +16,7 @@ var featuresList = map[models.FeatureSupportLevelID]SupportLevelFeature{
models.FeatureSupportLevelIDSINGLENODEEXPANSION: (&SingleNodeExpansionFeature{}).New(),
models.FeatureSupportLevelIDMINIMALISO: (&MinimalIso{}).New(),
models.FeatureSupportLevelIDFULLISO: (&FullIso{}).New(),
models.FeatureSupportLevelIDSKIPMCOREBOOT: &skipMcoReboot{},

// Network features
models.FeatureSupportLevelIDVIPAUTOALLOC: (&VipAutoAllocFeature{}).New(),
Expand Down
6 changes: 3 additions & 3 deletions internal/featuresupport/feature_support_test.go
Expand Up @@ -197,18 +197,18 @@ var _ = Describe("V2ListFeatureSupportLevels API", func() {
for _, platform := range platforms {
p := platform
list := GetFeatureSupportList("dummy", nil, &p)
Expect(len(list)).To(Equal(16))
Expect(len(list)).To(Equal(17))
}
})

It("GetFeatureSupportList 4.12", func() {
list := GetFeatureSupportList("4.12", nil, nil)
Expect(len(list)).To(Equal(20))
Expect(len(list)).To(Equal(21))
})

It("GetFeatureSupportList 4.13", func() {
list := GetFeatureSupportList("4.13", nil, nil)
Expect(len(list)).To(Equal(20))
Expect(len(list)).To(Equal(21))
})

It("GetCpuArchitectureSupportList 4.12", func() {
Expand Down
42 changes: 42 additions & 0 deletions internal/featuresupport/features_misc.go
Expand Up @@ -249,3 +249,45 @@ func (feature *FullIso) getFeatureActiveLevel(_ *common.Cluster, infraEnv *model
}
return activeLevelNotActive
}

// Skip MCO reboot
type skipMcoReboot struct{}

func (f *skipMcoReboot) New() SupportLevelFeature {
return &skipMcoReboot{}
}

func (f *skipMcoReboot) getId() models.FeatureSupportLevelID {
return models.FeatureSupportLevelIDSKIPMCOREBOOT
}

func (f *skipMcoReboot) GetName() string {
return "Skip MCO reboot"
}

func (f *skipMcoReboot) getSupportLevel(filters SupportLevelFilters) models.SupportLevel {
enableSkipMcoReboot, err := common.BaseVersionGreaterOrEqual("4.15.0", filters.OpenshiftVersion)
if !enableSkipMcoReboot || err != nil {
return models.SupportLevelUnavailable
}
return models.SupportLevelSupported
}

func (f *skipMcoReboot) getIncompatibleFeatures(openshiftVersion string) *[]models.FeatureSupportLevelID {
return nil
}

func (f *skipMcoReboot) getIncompatibleArchitectures(openshiftVersion *string) *[]models.ArchitectureSupportLevelID {
return nil
}

func (f *skipMcoReboot) getFeatureActiveLevel(cluster *common.Cluster, infraEnv *models.InfraEnv,
clusterUpdateParams *models.V2ClusterUpdateParams, infraenvUpdateParams *models.InfraEnvUpdateParams) featureActiveLevel {
if cluster != nil {
active, err := common.BaseVersionGreaterOrEqual("4.15.0", cluster.OpenshiftVersion)
if err != nil || !active {
return activeLevelNotActive
}
}
return activeLevelActive
}
8 changes: 7 additions & 1 deletion internal/host/hostcommands/install_cmd.go
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/openshift/assisted-service/internal/common"
eventgen "github.com/openshift/assisted-service/internal/common/events"
eventsapi "github.com/openshift/assisted-service/internal/events/api"
"github.com/openshift/assisted-service/internal/featuresupport"
"github.com/openshift/assisted-service/internal/hardware"
"github.com/openshift/assisted-service/internal/host/hostutil"
"github.com/openshift/assisted-service/internal/network"
Expand All @@ -24,6 +25,8 @@ import (
"gorm.io/gorm"
)

const baseVersionForSkipMcoReboot = "4.15.0"

type installCmd struct {
baseCmd
db *gorm.DB
Expand Down Expand Up @@ -114,7 +117,10 @@ func (i *installCmd) getFullInstallerCommand(ctx context.Context, cluster *commo
CheckCvo: swag.Bool(i.instructionConfig.CheckClusterVersion),
InstallerImage: swag.String(i.instructionConfig.InstallerImage),
BootDevice: swag.String(bootdevice),
EnableSkipMcoReboot: i.enableSkipMcoReboot,
}
if i.enableSkipMcoReboot {
request.EnableSkipMcoReboot = featuresupport.IsFeatureAvailable(models.FeatureSupportLevelIDSKIPMCOREBOOT,
cluster.OpenshiftVersion, swag.String(cluster.CPUArchitecture))
}

// those flags are not used on day2 installation
Expand Down
32 changes: 18 additions & 14 deletions internal/host/hostcommands/install_cmd_test.go
Expand Up @@ -108,16 +108,20 @@ var _ = Describe("installcmd", func() {
})
})
DescribeTable("enable MCO reboot values",
func(enableMcoReboot bool) {
func(enableMcoReboot bool, version string, expected bool) {
installCommand := NewInstallCmd(common.GetTestLog(), db, mockValidator, mockRelease, instructionConfig, mockEvents, mockVersions, enableMcoReboot)
mockValidator.EXPECT().GetHostInstallationPath(gomock.Any()).Return(common.TestDiskId).Times(1)
mockGetReleaseImage(1)
mockImages(1)
Expect(db.Model(&common.Cluster{}).Where("id = ?", *host.ClusterID).Update("openshift_version", version).Error).ToNot(HaveOccurred())
installCmdSteps, stepErr = installCommand.GetSteps(ctx, &host)
validateInstallCommand(installCommand, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, enableMcoReboot)
validateInstallCommand(installCommand, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, expected, version)
},
Entry("Enbale MCO reboot is false", false),
Entry("Enbale MCO reboot is true", true),
Entry("Enbale MCO reboot is false", false, "4.15.0", false),
Entry("Enbale MCO reboot is true. Lower version", true, "4.14.0", false),
Entry("Enbale MCO reboot is true. Equal version", true, "4.15.0", true),
Entry("Enbale MCO reboot is true. Higher version", true, "4.16.0", true),
Entry("Enbale MCO reboot is true. Empty version", true, "", false),
)

It("get_step_one_master_success", func() {
Expand All @@ -126,7 +130,7 @@ var _ = Describe("installcmd", func() {
mockImages(1)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
hostFromDb := hostutil.GetHostFromDB(*host.ID, infraEnvId, db)
Expect(hostFromDb.InstallerVersion).Should(Equal(DefaultInstructionConfig.InstallerImage))
})
Expand All @@ -139,13 +143,13 @@ var _ = Describe("installcmd", func() {
mockImages(3)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host2)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host2.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host2.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host3)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleBootstrap)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleBootstrap, infraEnvId, clusterId, *host3.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleBootstrap, infraEnvId, clusterId, *host3.ID, common.TestDiskId, nil, models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
})
It("invalid_inventory", func() {
host.Inventory = "blah"
Expand Down Expand Up @@ -231,7 +235,7 @@ var _ = Describe("installcmd", func() {
prepareGetStep(sdb)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sdb.ID, getBootableDiskNames(disks), models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sdb.ID, getBootableDiskNames(disks), models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
hostFromDb := hostutil.GetHostFromDB(*host.ID, infraEnvId, db)
Expect(hostFromDb.InstallerVersion).Should(Equal(DefaultInstructionConfig.InstallerImage))
verifyDiskFormatCommand(installCmdSteps[0], sda.ID, true)
Expand All @@ -252,7 +256,7 @@ var _ = Describe("installcmd", func() {
prepareGetStep(sddd)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sddd.ID, getBootableDiskNames(disks), models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sddd.ID, getBootableDiskNames(disks), models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
hostFromDb := hostutil.GetHostFromDB(*host.ID, infraEnvId, db)
Expect(hostFromDb.InstallerVersion).Should(Equal(DefaultInstructionConfig.InstallerImage))
verifyDiskFormatCommand(installCmdSteps[0], sda.ID, true)
Expand All @@ -274,7 +278,7 @@ var _ = Describe("installcmd", func() {
prepareGetStep(sddd)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sddd.ID, getBootableDiskNames(disks), models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sddd.ID, getBootableDiskNames(disks), models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
hostFromDb := hostutil.GetHostFromDB(*host.ID, infraEnvId, db)
Expect(hostFromDb.InstallerVersion).Should(Equal(DefaultInstructionConfig.InstallerImage))
verifyDiskFormatCommand(installCmdSteps[0], sda.ID, true)
Expand Down Expand Up @@ -320,7 +324,7 @@ var _ = Describe("installcmd", func() {
prepareGetStep(sdb)
installCmdSteps, stepErr = installCmd.GetSteps(ctx, &host)
postvalidation(false, false, installCmdSteps[0], stepErr, models.HostRoleMaster)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sdb.ID, []string{sda.ID, sdc.ID}, models.ClusterHighAvailabilityModeFull, true)
validateInstallCommand(installCmd, installCmdSteps[0], models.HostRoleMaster, infraEnvId, clusterId, *host.ID, sdb.ID, []string{sda.ID, sdc.ID}, models.ClusterHighAvailabilityModeFull, false, common.TestDefaultConfig.OpenShiftVersion)
hostFromDb := hostutil.GetHostFromDB(*host.ID, infraEnvId, db)
Expect(hostFromDb.InstallerVersion).Should(Equal(DefaultInstructionConfig.InstallerImage))
verifyDiskFormatCommand(installCmdSteps[0], sda.ID, true)
Expand Down Expand Up @@ -1187,7 +1191,7 @@ func postvalidation(isstepreplynil bool, issteperrnil bool, expectedstepreply *m
}

func validateInstallCommand(installCmd *installCmd, reply *models.Step, role models.HostRole, infraEnvId, clusterId, hostId strfmt.UUID,
bootDevice string, bootableDisks []string, haMode string, enableSkipMcoReboot bool) {
bootDevice string, bootableDisks []string, haMode string, enableSkipMcoReboot bool, version string) {
ExpectWithOffset(1, reply.StepType).To(Equal(models.StepTypeInstall))
mustGatherImage, _ := installCmd.getMustGatherArgument(defaultMustGatherVersion)
request := models.InstallCmdRequest{}
Expand All @@ -1197,7 +1201,7 @@ func validateInstallCommand(installCmd *installCmd, reply *models.Step, role mod
Expect(request.ClusterID.String()).To(Equal(clusterId.String()))
Expect(request.HostID.String()).To(Equal(hostId.String()))
Expect(swag.StringValue(request.HighAvailabilityMode)).To(Equal(haMode))
Expect(request.OpenshiftVersion).To(Equal(common.TestDefaultConfig.OpenShiftVersion))
Expect(request.OpenshiftVersion).To(Equal(version))
Expect(*request.Role).To(Equal(role))
Expect(swag.StringValue(request.BootDevice)).To(Equal(bootDevice))
Expect(request.McoImage).To(Equal(defaultMCOImage))
Expand Down
5 changes: 4 additions & 1 deletion models/feature_support_level_id.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions swagger.yaml
Expand Up @@ -4064,6 +4064,7 @@ definitions:
- 'EXTERNAL_PLATFORM_OCI'
- 'DUAL_STACK'
- 'PLATFORM_MANAGED_NETWORKING'
- 'SKIP_MCO_REBOOT'

architecture-support-level-id:
type: string
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6aaef89

Please sign in to comment.