Skip to content

Commit fc095f4

Browse files
committed
MGMT-20324: Disable feature validation when creating and updating assisted objects due to an error when user is trying to add hosts on day2 with P/Z arch
1 parent 7e3ad83 commit fc095f4

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

internal/featuresupport/common.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ func ValidateActiveFeatures(log logrus.FieldLogger, cluster *common.Cluster, inf
2323
if cluster == nil {
2424
return err
2525
}
26+
27+
if swag.StringValue(cluster.Kind) == models.ClusterKindAddHostsCluster {
28+
log.Infof("skipping feature support validation: cluster %s is of kind AddHostsCluster", cluster.ID.String())
29+
return nil
30+
}
31+
2632
activatedFeatures := getActivatedFeatures(log, cluster, infraEnv, updateParams)
2733
for _, feature := range activatedFeatures {
2834
logFields := logrus.Fields{
@@ -51,6 +57,10 @@ func ValidateIncompatibleFeatures(log logrus.FieldLogger, cpuArchitecture string
5157
if cluster != nil {
5258
openshiftVersion = &cluster.OpenshiftVersion
5359
}
60+
if cluster != nil && swag.StringValue(cluster.Kind) == models.ClusterKindAddHostsCluster {
61+
log.Infof("skipping feature support validation: cluster %s is of kind AddHostsCluster", cluster.ID.String())
62+
return nil
63+
}
5464

5565
activatedFeatures := getActivatedFeatures(log, cluster, infraEnv, updateParams)
5666
if cpuArchitecture != "" && swag.StringValue(openshiftVersion) != "" {

internal/featuresupport/feature_support_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package featuresupport
22

33
import (
4+
"bytes"
45
"fmt"
56
"testing"
67

8+
"github.com/go-openapi/strfmt"
79
"github.com/go-openapi/swag"
810
. "github.com/onsi/ginkgo"
911
. "github.com/onsi/ginkgo/extensions/table"
@@ -457,6 +459,29 @@ var _ = Describe("V2ListFeatureSupportLevels API", func() {
457459
params := models.V2ClusterUpdateParams{UserManagedNetworking: swag.Bool(false)}
458460
Expect(ValidateIncompatibleFeatures(log, models.ClusterCPUArchitectureS390x, &cluster, nil, &params)).To(Not(BeNil()))
459461
})
462+
It("Ignore validation on AddHostCluster", func() {
463+
logBuffer := bytes.Buffer{}
464+
testLogger := logrus.New()
465+
testLogger.SetOutput(&logBuffer)
466+
467+
clusterID := strfmt.UUID("e679ea3f-3b85-40e0-8dc9-82fd6945d9b2")
468+
cluster := common.Cluster{Cluster: models.Cluster{
469+
ID: &clusterID,
470+
OpenshiftVersion: "4.19",
471+
Kind: swag.String(models.ClusterKindAddHostsCluster),
472+
CPUArchitecture: models.ClusterCPUArchitectureS390x,
473+
ControlPlaneCount: common.MinMasterHostsNeededForInstallationInHaMode,
474+
Platform: &models.Platform{Type: common.PlatformTypePtr(models.PlatformTypeNone)},
475+
}}
476+
477+
infraEnv := models.InfraEnv{
478+
ClusterID: *cluster.ID,
479+
CPUArchitecture: models.ClusterCPUArchitectureS390x,
480+
}
481+
482+
Expect(ValidateActiveFeatures(logrus.NewEntry(testLogger), &cluster, &infraEnv, nil)).To(BeNil())
483+
Expect(logBuffer.String()).To(ContainSubstring("skipping feature support validation:"))
484+
})
460485
It("Update s390x cluster", func() {
461486
cluster := common.Cluster{Cluster: models.Cluster{
462487
OpenshiftVersion: "4.13",
@@ -866,6 +891,30 @@ var _ = Describe("V2ListFeatureSupportLevels API", func() {
866891
})
867892

868893
Context("Test validate active features", func() {
894+
It("Ignore validation on AddHostCluster", func() {
895+
logBuffer := bytes.Buffer{}
896+
testLogger := logrus.New()
897+
testLogger.SetOutput(&logBuffer)
898+
899+
clusterID := strfmt.UUID("e679ea3f-3b85-40e0-8dc9-82fd6945d9b2")
900+
cluster := common.Cluster{Cluster: models.Cluster{
901+
ID: &clusterID,
902+
OpenshiftVersion: "4.19",
903+
Kind: swag.String(models.ClusterKindAddHostsCluster),
904+
CPUArchitecture: models.ClusterCPUArchitectureS390x,
905+
ControlPlaneCount: common.MinMasterHostsNeededForInstallationInHaMode,
906+
Platform: &models.Platform{Type: common.PlatformTypePtr(models.PlatformTypeNone)},
907+
}}
908+
909+
infraEnv := models.InfraEnv{
910+
ClusterID: *cluster.ID,
911+
CPUArchitecture: models.ClusterCPUArchitectureS390x,
912+
}
913+
914+
Expect(ValidateIncompatibleFeatures(logrus.NewEntry(testLogger), models.ClusterCPUArchitectureS390x, &cluster, &infraEnv, nil)).To(BeNil())
915+
Expect(logBuffer.String()).To(ContainSubstring("skipping feature support validation:"))
916+
})
917+
869918
DescribeTable(
870919
"Valid VipDhcpAllocation and OpenShift version",
871920
func(openshiftVersion string) {

0 commit comments

Comments
 (0)