From ffa89b9667ea9400c8fa4618087d53f42dcd3704 Mon Sep 17 00:00:00 2001 From: xiangchun Fu Date: Sun, 24 Nov 2024 06:43:33 -0500 Subject: [PATCH] change error Signed-off-by: xiangchun Fu --- .../models/cluster_validation_id.go | 5 +- .../models/feature_support_level_id.go | 5 +- .../models/host_validation_id.go | 5 +- .../featuresupport/feature_support_level.go | 2 +- .../featuresupport/feature_support_test.go | 6 +- .../featuresupport/features_olm_operators.go | 28 +++---- .../features_olm_operators_test.go | 31 +++++++ internal/operators/osc/config.go | 13 +-- internal/operators/osc/manifest.go | 83 +++---------------- internal/operators/osc/manifest_test.go | 18 ++-- internal/operators/osc/operator.go | 4 +- internal/operators/osc/operator_test.go | 6 -- subsystem/cluster_test.go | 10 ++- subsystem/operators_test.go | 2 + 14 files changed, 97 insertions(+), 121 deletions(-) diff --git a/client/vendor/github.com/openshift/assisted-service/models/cluster_validation_id.go b/client/vendor/github.com/openshift/assisted-service/models/cluster_validation_id.go index 7b3b0e4c860..6013412051a 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/cluster_validation_id.go +++ b/client/vendor/github.com/openshift/assisted-service/models/cluster_validation_id.go @@ -99,6 +99,9 @@ const ( // ClusterValidationIDMtvRequirementsSatisfied captures enum value "mtv-requirements-satisfied" ClusterValidationIDMtvRequirementsSatisfied ClusterValidationID = "mtv-requirements-satisfied" + // ClusterValidationIDOscRequirementsSatisfied captures enum value "osc-requirements-satisfied" + ClusterValidationIDOscRequirementsSatisfied ClusterValidationID = "osc-requirements-satisfied" + // ClusterValidationIDNetworkTypeValid captures enum value "network-type-valid" ClusterValidationIDNetworkTypeValid ClusterValidationID = "network-type-valid" @@ -129,7 +132,7 @@ var clusterValidationIdEnum []interface{} func init() { var res []ClusterValidationID - if err := json.Unmarshal([]byte(`["machine-cidr-defined","cluster-cidr-defined","service-cidr-defined","no-cidrs-overlapping","networks-same-address-families","network-prefix-valid","machine-cidr-equals-to-calculated-cidr","api-vips-defined","api-vips-valid","ingress-vips-defined","ingress-vips-valid","all-hosts-are-ready-to-install","sufficient-masters-count","dns-domain-defined","pull-secret-set","ntp-server-configured","lso-requirements-satisfied","ocs-requirements-satisfied","odf-requirements-satisfied","cnv-requirements-satisfied","lvm-requirements-satisfied","mce-requirements-satisfied","mtv-requirements-satisfied","network-type-valid","platform-requirements-satisfied","node-feature-discovery-requirements-satisfied","nvidia-gpu-requirements-satisfied","pipelines-requirements-satisfied","servicemesh-requirements-satisfied","serverless-requirements-satisfied","openshift-ai-requirements-satisfied"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["machine-cidr-defined","cluster-cidr-defined","service-cidr-defined","no-cidrs-overlapping","networks-same-address-families","network-prefix-valid","machine-cidr-equals-to-calculated-cidr","api-vips-defined","api-vips-valid","ingress-vips-defined","ingress-vips-valid","all-hosts-are-ready-to-install","sufficient-masters-count","dns-domain-defined","pull-secret-set","ntp-server-configured","lso-requirements-satisfied","ocs-requirements-satisfied","odf-requirements-satisfied","cnv-requirements-satisfied","lvm-requirements-satisfied","mce-requirements-satisfied","mtv-requirements-satisfied","osc-requirements-satisfied","network-type-valid","platform-requirements-satisfied","node-feature-discovery-requirements-satisfied","nvidia-gpu-requirements-satisfied","pipelines-requirements-satisfied","servicemesh-requirements-satisfied","serverless-requirements-satisfied","openshift-ai-requirements-satisfied"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/client/vendor/github.com/openshift/assisted-service/models/feature_support_level_id.go b/client/vendor/github.com/openshift/assisted-service/models/feature_support_level_id.go index 2a7d4ad667f..29fb6623ae0 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/feature_support_level_id.go +++ b/client/vendor/github.com/openshift/assisted-service/models/feature_support_level_id.go @@ -60,6 +60,9 @@ const ( // FeatureSupportLevelIDMTV captures enum value "MTV" FeatureSupportLevelIDMTV FeatureSupportLevelID = "MTV" + // FeatureSupportLevelIDOSC captures enum value "OSC" + FeatureSupportLevelIDOSC FeatureSupportLevelID = "OSC" + // FeatureSupportLevelIDNUTANIXINTEGRATION captures enum value "NUTANIX_INTEGRATION" FeatureSupportLevelIDNUTANIXINTEGRATION FeatureSupportLevelID = "NUTANIX_INTEGRATION" @@ -132,7 +135,7 @@ var featureSupportLevelIdEnum []interface{} func init() { var res []FeatureSupportLevelID - if err := json.Unmarshal([]byte(`["SNO","VIP_AUTO_ALLOC","CUSTOM_MANIFEST","SINGLE_NODE_EXPANSION","LVM","ODF","LSO","CNV","MCE","MTV","NUTANIX_INTEGRATION","BAREMETAL_PLATFORM","NONE_PLATFORM","VSPHERE_INTEGRATION","DUAL_STACK_VIPS","CLUSTER_MANAGED_NETWORKING","USER_MANAGED_NETWORKING","MINIMAL_ISO","FULL_ISO","EXTERNAL_PLATFORM_OCI","DUAL_STACK","PLATFORM_MANAGED_NETWORKING","SKIP_MCO_REBOOT","EXTERNAL_PLATFORM","OVN_NETWORK_TYPE","SDN_NETWORK_TYPE","NODE_FEATURE_DISCOVERY","NVIDIA_GPU","PIPELINES","SERVICEMESH","SERVERLESS","OPENSHIFT_AI"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["SNO","VIP_AUTO_ALLOC","CUSTOM_MANIFEST","SINGLE_NODE_EXPANSION","LVM","ODF","LSO","CNV","MCE","MTV","OSC","NUTANIX_INTEGRATION","BAREMETAL_PLATFORM","NONE_PLATFORM","VSPHERE_INTEGRATION","DUAL_STACK_VIPS","CLUSTER_MANAGED_NETWORKING","USER_MANAGED_NETWORKING","MINIMAL_ISO","FULL_ISO","EXTERNAL_PLATFORM_OCI","DUAL_STACK","PLATFORM_MANAGED_NETWORKING","SKIP_MCO_REBOOT","EXTERNAL_PLATFORM","OVN_NETWORK_TYPE","SDN_NETWORK_TYPE","NODE_FEATURE_DISCOVERY","NVIDIA_GPU","PIPELINES","SERVICEMESH","SERVERLESS","OPENSHIFT_AI"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/client/vendor/github.com/openshift/assisted-service/models/host_validation_id.go b/client/vendor/github.com/openshift/assisted-service/models/host_validation_id.go index f307e57b173..3f8fa0170e9 100644 --- a/client/vendor/github.com/openshift/assisted-service/models/host_validation_id.go +++ b/client/vendor/github.com/openshift/assisted-service/models/host_validation_id.go @@ -102,6 +102,9 @@ const ( // HostValidationIDMtvRequirementsSatisfied captures enum value "mtv-requirements-satisfied" HostValidationIDMtvRequirementsSatisfied HostValidationID = "mtv-requirements-satisfied" + // HostValidationIDOscRequirementsSatisfied captures enum value "osc-requirements-satisfied" + HostValidationIDOscRequirementsSatisfied HostValidationID = "osc-requirements-satisfied" + // HostValidationIDSufficientInstallationDiskSpeed captures enum value "sufficient-installation-disk-speed" HostValidationIDSufficientInstallationDiskSpeed HostValidationID = "sufficient-installation-disk-speed" @@ -183,7 +186,7 @@ var hostValidationIdEnum []interface{} func init() { var res []HostValidationID - if err := json.Unmarshal([]byte(`["connected","media-connected","has-inventory","has-min-cpu-cores","has-min-valid-disks","has-min-memory","machine-cidr-defined","has-cpu-cores-for-role","has-memory-for-role","hostname-unique","hostname-valid","belongs-to-machine-cidr","ignition-downloadable","belongs-to-majority-group","valid-platform-network-settings","ntp-synced","time-synced-between-host-and-service","container-images-available","lso-requirements-satisfied","ocs-requirements-satisfied","odf-requirements-satisfied","lvm-requirements-satisfied","mce-requirements-satisfied","mtv-requirements-satisfied","sufficient-installation-disk-speed","cnv-requirements-satisfied","sufficient-network-latency-requirement-for-role","sufficient-packet-loss-requirement-for-role","has-default-route","api-domain-name-resolved-correctly","api-int-domain-name-resolved-correctly","apps-domain-name-resolved-correctly","release-domain-name-resolved-correctly","compatible-with-cluster-platform","dns-wildcard-not-configured","disk-encryption-requirements-satisfied","non-overlapping-subnets","vsphere-disk-uuid-enabled","compatible-agent","no-skip-installation-disk","no-skip-missing-disk","no-ip-collisions-in-network","no-iscsi-nic-belongs-to-machine-cidr","node-feature-discovery-requirements-satisfied","nvidia-gpu-requirements-satisfied","pipelines-requirements-satisfied","servicemesh-requirements-satisfied","serverless-requirements-satisfied","openshift-ai-requirements-satisfied"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["connected","media-connected","has-inventory","has-min-cpu-cores","has-min-valid-disks","has-min-memory","machine-cidr-defined","has-cpu-cores-for-role","has-memory-for-role","hostname-unique","hostname-valid","belongs-to-machine-cidr","ignition-downloadable","belongs-to-majority-group","valid-platform-network-settings","ntp-synced","time-synced-between-host-and-service","container-images-available","lso-requirements-satisfied","ocs-requirements-satisfied","odf-requirements-satisfied","lvm-requirements-satisfied","mce-requirements-satisfied","mtv-requirements-satisfied","osc-requirements-satisfied","sufficient-installation-disk-speed","cnv-requirements-satisfied","sufficient-network-latency-requirement-for-role","sufficient-packet-loss-requirement-for-role","has-default-route","api-domain-name-resolved-correctly","api-int-domain-name-resolved-correctly","apps-domain-name-resolved-correctly","release-domain-name-resolved-correctly","compatible-with-cluster-platform","dns-wildcard-not-configured","disk-encryption-requirements-satisfied","non-overlapping-subnets","vsphere-disk-uuid-enabled","compatible-agent","no-skip-installation-disk","no-skip-missing-disk","no-ip-collisions-in-network","no-iscsi-nic-belongs-to-machine-cidr","node-feature-discovery-requirements-satisfied","nvidia-gpu-requirements-satisfied","pipelines-requirements-satisfied","servicemesh-requirements-satisfied","serverless-requirements-satisfied","openshift-ai-requirements-satisfied"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/internal/featuresupport/feature_support_level.go b/internal/featuresupport/feature_support_level.go index 8401fdd4323..3fe2c1a9254 100644 --- a/internal/featuresupport/feature_support_level.go +++ b/internal/featuresupport/feature_support_level.go @@ -35,7 +35,7 @@ var featuresList = map[models.FeatureSupportLevelID]SupportLevelFeature{ models.FeatureSupportLevelIDMCE: (&MceFeature{}).New(), models.FeatureSupportLevelIDODF: (&OdfFeature{}).New(), models.FeatureSupportLevelIDMTV: (&MtvFeature{}).New(), - models.FeatureSupportLevelIDOSC: (&OSCFeature{}).New(), + models.FeatureSupportLevelIDOSC: (&OscFeature{}).New(), models.FeatureSupportLevelIDNODEFEATUREDISCOVERY: (&NodeFeatureDiscoveryFeature{}).New(), models.FeatureSupportLevelIDNVIDIAGPU: (&NvidiaGPUFeature{}).New(), models.FeatureSupportLevelIDPIPELINES: (&PipelinesFeature{}).New(), diff --git a/internal/featuresupport/feature_support_test.go b/internal/featuresupport/feature_support_test.go index 7a31b8801c8..2bc5d0d90c2 100644 --- a/internal/featuresupport/feature_support_test.go +++ b/internal/featuresupport/feature_support_test.go @@ -269,19 +269,19 @@ var _ = Describe("V2ListFeatureSupportLevels API", func() { When("GetFeatureSupportList 4.12 with Platform", func() { It(string(*filters.PlatformType)+" "+swag.StringValue(filters.ExternalPlatformName), func() { list := GetFeatureSupportList("dummy", nil, filters.PlatformType, filters.ExternalPlatformName) - Expect(len(list)).To(Equal(26)) + Expect(len(list)).To(Equal(27)) }) }) } It("GetFeatureSupportList 4.12", func() { list := GetFeatureSupportList("4.12", nil, nil, nil) - Expect(len(list)).To(Equal(31)) + Expect(len(list)).To(Equal(32)) }) It("GetFeatureSupportList 4.13", func() { list := GetFeatureSupportList("4.13", nil, nil, nil) - Expect(len(list)).To(Equal(31)) + Expect(len(list)).To(Equal(32)) }) It("GetCpuArchitectureSupportList 4.12", func() { diff --git a/internal/featuresupport/features_olm_operators.go b/internal/featuresupport/features_olm_operators.go index ccf8729a709..09dbd65f0fd 100644 --- a/internal/featuresupport/features_olm_operators.go +++ b/internal/featuresupport/features_olm_operators.go @@ -591,38 +591,38 @@ func (f *OpenShiftAIFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *m return activeLevelNotActive } -// OSCFeature -type OSCFeature struct{} +// OscFeature +type OscFeature struct{} -func (feature *OSCFeature) New() SupportLevelFeature { - return &OSCFeature{} +func (feature *OscFeature) New() SupportLevelFeature { + return &OscFeature{} } -func (feature *OSCFeature) getId() models.FeatureSupportLevelID { +func (feature *OscFeature) getId() models.FeatureSupportLevelID { return models.FeatureSupportLevelIDOSC } -func (feature *OSCFeature) GetName() string { - return "OpenShift Sandboxed Containers" +func (feature *OscFeature) GetName() string { + return "OpenShift sandboxed containers" } -func (feature *OSCFeature) getSupportLevel(filters SupportLevelFilters) models.SupportLevel { +func (feature *OscFeature) getSupportLevel(filters SupportLevelFilters) models.SupportLevel { if !isFeatureCompatibleWithArchitecture(feature, filters.OpenshiftVersion, swag.StringValue(filters.CPUArchitecture)) { return models.SupportLevelUnavailable } - if filters.PlatformType != nil && (*filters.PlatformType == models.PlatformTypeVsphere || *filters.PlatformType == models.PlatformTypeNutanix || *filters.PlatformType == models.PlatformTypeNone) { + if filters.PlatformType != nil && (*filters.PlatformType == models.PlatformTypeVsphere || *filters.PlatformType == models.PlatformTypeNutanix) { return models.SupportLevelUnavailable } - if isNotSupported, err := common.BaseVersionLessThan("4.17", filters.OpenshiftVersion); isNotSupported || err != nil { + if isNotSupported, err := common.BaseVersionLessThan("4.10", filters.OpenshiftVersion); isNotSupported || err != nil { return models.SupportLevelUnavailable } return models.SupportLevelSupported } -func (feature *OSCFeature) getIncompatibleArchitectures(_ *string) *[]models.ArchitectureSupportLevelID { +func (feature *OscFeature) getIncompatibleArchitectures(_ *string) *[]models.ArchitectureSupportLevelID { incompatibleArchitecture := []models.ArchitectureSupportLevelID{ models.ArchitectureSupportLevelIDARM64ARCHITECTURE, models.ArchitectureSupportLevelIDS390XARCHITECTURE, @@ -631,15 +631,15 @@ func (feature *OSCFeature) getIncompatibleArchitectures(_ *string) *[]models.Arc return &incompatibleArchitecture } -func (feature *OSCFeature) getIncompatibleFeatures(string) *[]models.FeatureSupportLevelID { +func (feature *OscFeature) getIncompatibleFeatures(string) *[]models.FeatureSupportLevelID { return &[]models.FeatureSupportLevelID{ models.FeatureSupportLevelIDNUTANIXINTEGRATION, models.FeatureSupportLevelIDVSPHEREINTEGRATION, } } -func (feature *OSCFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *models.InfraEnv, clusterUpdateParams *models.V2ClusterUpdateParams, _ *models.InfraEnvUpdateParams) featureActiveLevel { - if isOperatorActivated("OSC", cluster, clusterUpdateParams) && isOperatorActivated("cnv", cluster, clusterUpdateParams) { +func (feature *OscFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *models.InfraEnv, clusterUpdateParams *models.V2ClusterUpdateParams, _ *models.InfraEnvUpdateParams) featureActiveLevel { + if isOperatorActivated("osc", cluster, clusterUpdateParams) { return activeLevelActive } return activeLevelNotActive diff --git a/internal/featuresupport/features_olm_operators_test.go b/internal/featuresupport/features_olm_operators_test.go index e502f2be4a7..0f06d1b010c 100644 --- a/internal/featuresupport/features_olm_operators_test.go +++ b/internal/featuresupport/features_olm_operators_test.go @@ -269,4 +269,35 @@ var _ = Describe("V2ListFeatureSupportLevels API", func() { Entry("on baremetal", "4.13", common.X86CPUArchitecture, models.PlatformTypeBaremetal, models.SupportLevelUnavailable), ) }) + + Context("Test OSC feature", func() { + DescribeTable("Validate OSC on Architecture", func(ocpVersion []string, cpuArch string, expectedResult bool) { + for _, v := range ocpVersion { + version := v + result := IsFeatureAvailable(models.FeatureSupportLevelIDOSC, version, swag.String(cpuArch)) + Expect(result).Should(Equal(expectedResult), + fmt.Sprintf("Feature: %s, OCP version: %s, CpuArch: %s, should be %v", models.FeatureSupportLevelIDOSC, v, cpuArch, expectedResult)) + } + }, + Entry("on X86 is supported above 4.10", []string{"4.15", "4.16", "4.17", "4.21"}, models.ClusterCPUArchitectureX8664, true), + Entry("on arm64 is NOT supported", []string{"4.8", "4.11", "4.14", "4.21"}, models.ClusterCPUArchitectureArm64, false), + Entry("on S390x is NOT supported", []string{"4.11", "4.13", "4.14", "4.21"}, models.ClusterCPUArchitectureS390x, false), + Entry("on ppc64le is NOT supported", []string{"4.11", "4.13", "4.14", "4.21"}, models.ClusterCPUArchitecturePpc64le, false), + ) + + DescribeTable("Validate OSC on platform", func(ocpVersion string, cpuArch string, platformType models.PlatformType, expectedResult models.SupportLevel) { + featureSupportLevels := GetFeatureSupportList( + ocpVersion, + swag.String(cpuArch), + common.PlatformTypePtr(platformType), + nil, + ) + Expect(featureSupportLevels[string(models.FeatureSupportLevelIDOSC)]).To(Equal(expectedResult)) + }, + Entry("on Vsphere", "4.10", common.X86CPUArchitecture, models.PlatformTypeVsphere, models.SupportLevelUnavailable), + Entry("on Nutanix", "4.10", common.X86CPUArchitecture, models.PlatformTypeNutanix, models.SupportLevelUnavailable), + Entry("on none", "4.10", common.X86CPUArchitecture, models.PlatformTypeNone, models.SupportLevelSupported), + Entry("on baremetal", "4.10", common.X86CPUArchitecture, models.PlatformTypeBaremetal, models.SupportLevelSupported), + ) + }) }) diff --git a/internal/operators/osc/config.go b/internal/operators/osc/config.go index 0f41762b597..ec86d0bdd42 100644 --- a/internal/operators/osc/config.go +++ b/internal/operators/osc/config.go @@ -2,21 +2,16 @@ package osc const ( Name = "osc" - FullName = "OpenShift Sandboxed Containers" + FullName = "OpenShift sandboxed containers" Namespace = "openshift-sandboxed-containers-operator" - Subscription = "osc-operator" + SubscriptionName = "osc-operator" Source = "redhat-operators" SourceName = "osc-operator" - OscMinOpenshiftVersion = "4.17.0" - LayeredImageDeployment = "true" - LayeredImageUrl = "quay.io/fidencio/rhcos-layer/ocp-4.16:tdx-20241003-1327" - KernelArgs = "kvm_intel.tdx=1" + OscMinOpenshiftVersion = "4.10.0" + // Memory value provided in GiB MasterMemory int64 = 1 MasterCPU int64 = 1 - // Memory value provided in GIB - WorkerMemory int64 = 1 - WorkerCPU int64 = 1 ) type Config struct { diff --git a/internal/operators/osc/manifest.go b/internal/operators/osc/manifest.go index 6d4d8b3f5e5..8ee333a7fe4 100644 --- a/internal/operators/osc/manifest.go +++ b/internal/operators/osc/manifest.go @@ -7,33 +7,28 @@ import ( func Manifests() (map[string][]byte, []byte, error) { - oscNamespace, err := getNamespace(Namespace) + oscNamespaceManifest, err := getNamespace(Namespace) if err != nil { return nil, nil, err } - oscOperatorGroup, err := getOperatorGroup(Namespace) + oscOperatorGroupManifest, err := getOperatorGroup(Namespace) if err != nil { return nil, nil, err } - oscSubscription, err := getSubscription(Namespace, Subscription, Source, SourceName) - if err != nil { - return nil, nil, err - } - - oscConfigMap, err := getConfigMap(Namespace, LayeredImageDeployment) + oscSubscriptionManifest, err := getSubscription(Namespace, SubscriptionName, Source, SourceName) if err != nil { return nil, nil, err } openshiftManifests := make(map[string][]byte) - openshiftManifests["50_openshift-osc_ns.yaml"] = oscNamespace - openshiftManifests["50_openshift-osc_operator_group.yaml"] = oscOperatorGroup - openshiftManifests["50_openshift-osc_subscription.yaml"] = oscSubscription + openshiftManifests["50_openshift-osc_ns.yaml"] = oscNamespaceManifest + openshiftManifests["50_openshift-osc_operator_group.yaml"] = oscOperatorGroupManifest + openshiftManifests["50_openshift-osc_subscription.yaml"] = oscSubscriptionManifest - return openshiftManifests, oscConfigMap, nil + return openshiftManifests, nil, err } func executeTemplate(data map[string]string, contentName, content string) ([]byte, error) { @@ -56,62 +51,31 @@ func getSubscription(namespace, subscription, source, sourceName string) ([]byte "OPERATOR_SOURCE": source, "OPERATOR_SOURCE_NAME": sourceName, } - return executeTemplate(data, "oscSubscription", oscSubscription) + return executeTemplate(data, "oscSubscriptionManifest", oscSubscriptionManifest) } func getNamespace(namespace string) ([]byte, error) { data := map[string]string{ "OPERATOR_NAMESPACE": namespace, } - return executeTemplate(data, "oscNamespace", oscNamespace) + return executeTemplate(data, "oscNamespaceManifest", oscNamespaceManifest) } func getOperatorGroup(namespace string) ([]byte, error) { data := map[string]string{ "OPERATOR_NAMESPACE": namespace, } - return executeTemplate(data, "oscGroup", oscGroup) -} - -func getConfigMap(namespace string, layeredImageDeployment string) ([]byte, error) { - data := map[string]string{ - "OPERATOR_NAMESPACE": namespace, - "OPERATOR_IS_LAYERED_IMAGE_DEPLOYMENT": layeredImageDeployment, - } - - if configMap, err := executeTemplate(data, "oscConfigMap", oscConfigMap); err != nil { - return nil, err - } else { - if layeredImageDeployment == "true" { - LayeredImageDeploymentConfigMap, err := getLayeredImageDeployConfigMap(namespace) - if err != nil { - return nil, err - } - configMap = append(configMap, []byte("\n---\n")...) - configMap = append(configMap, LayeredImageDeploymentConfigMap...) - - } - return configMap, nil - } + return executeTemplate(data, "oscOperatorGroupManifest", oscOperatorGroupManifest) } -func getLayeredImageDeployConfigMap(namespace string) ([]byte, error) { - data := map[string]string{ - "OPERATOR_NAMESPACE": namespace, - "OPERATOR_KERNEL_ARGS": KernelArgs, - "OPERATOR_OS_IMAGE_URL": LayeredImageUrl, - } - return executeTemplate(data, "oscLayeredImageDeployConfigMap", oscLayeredImageDeployConfigMap) -} - -const oscNamespace = ` +const oscNamespaceManifest = ` apiVersion: v1 kind: Namespace metadata: name: {{.OPERATOR_NAMESPACE}} ` -const oscGroup = ` +const oscOperatorGroupManifest = ` apiVersion: operators.coreos.com/v1 kind: OperatorGroup metadata: @@ -122,7 +86,7 @@ spec: - {{ .OPERATOR_NAMESPACE }} ` -const oscSubscription = ` +const oscSubscriptionManifest = ` apiVersion: operators.coreos.com/v1alpha1 kind: Subscription metadata: @@ -135,24 +99,3 @@ spec: name: {{.OPERATOR_SOURCE_NAME}} installPlanApproval: Automatic ` -const oscConfigMap = ` -apiVersion: v1 -kind: ConfigMap -metadata: - name: osc-feature-gates - namespace: {{.OPERATOR_NAMESPACE}} -data: - # layeredImageDeployment allows deploying Kata using RHCOS layered image - # This feature gate needs a ConfigMap named layered-image-deploy-cm - layeredImageDeployment: {{.OPERATOR_IS_LAYERED_IMAGE_DEPLOYMENT}} -` -const oscLayeredImageDeployConfigMap = ` -apiVersion: v1 -data: - osImageURL: {{.OPERATOR_OS_IMAGE_URL}} - kernelArguments: {{.OPERATOR_KERNEL_ARGS}} -kind: ConfigMap -metadata: - name: layered-image-deploy-cm - namespace: {{.OPERATOR_NAMESPACE}} -` diff --git a/internal/operators/osc/manifest_test.go b/internal/operators/osc/manifest_test.go index a5b96d160ef..af6ba730ff5 100644 --- a/internal/operators/osc/manifest_test.go +++ b/internal/operators/osc/manifest_test.go @@ -1,6 +1,7 @@ package osc import ( + "fmt" "strings" . "github.com/onsi/ginkgo" @@ -15,13 +16,12 @@ var _ = Describe("OSC manifest generation", func() { var cluster *common.Cluster getCluster := func(openshiftVersion string) *common.Cluster { - cluster := common.Cluster{Cluster: models.Cluster{ + return &common.Cluster{Cluster: models.Cluster{ OpenshiftVersion: openshiftVersion, }} - return &cluster } - Context("MVP manifest", func() { + Context("OSC manifest", func() { It("Check YAMLs of OSC", func() { cluster = getCluster("4.17.0") openshiftManifests, manifest, err := operator.GenerateManifests(cluster) @@ -38,14 +38,14 @@ var _ = Describe("OSC manifest generation", func() { } _, err = yaml.YAMLToJSON(manifest) - Expect(err).ShouldNot(HaveOccurred(), "yamltojson err: %v", err) + Expect(err).ShouldNot(HaveOccurred(), fmt.Sprintf("yamltojson err: %v", err)) }) It("Check Subscription manifest", func() { - subscriptionData, err := getSubscription(Namespace, Subscription, Source, SourceName) + subscriptionData, err := getSubscription(Namespace, SubscriptionName, Source, SourceName) Expect(err).To(BeNil()) - Expect(extractData(subscriptionData, "metadata.name")).To(Equal(Subscription)) + Expect(extractData(subscriptionData, "metadata.name")).To(Equal(SubscriptionName)) Expect(extractData(subscriptionData, "metadata.namespace")).To(Equal(Namespace)) Expect(extractData(subscriptionData, "spec.source")).To(Equal(Source)) @@ -66,12 +66,6 @@ var _ = Describe("OSC manifest generation", func() { Expect(extractData(opData, "metadata.namespace")).To(Equal(Namespace)) }) - It("Check ConfigMap manifest", func() { - controllerData, err := getConfigMap(Namespace, LayeredImageDeployment) - Expect(err).To(BeNil()) - - Expect(extractData(controllerData, "metadata.namespace")).To(Equal(Namespace)) - }) }) }) diff --git a/internal/operators/osc/operator.go b/internal/operators/osc/operator.go index 4c3b626bfc6..dfef49657c9 100644 --- a/internal/operators/osc/operator.go +++ b/internal/operators/osc/operator.go @@ -23,7 +23,7 @@ var Operator = models.MonitoredOperator{ Name: Name, Namespace: Namespace, OperatorType: models.OperatorTypeOlm, - SubscriptionName: Subscription, + SubscriptionName: SubscriptionName, TimeoutSeconds: 60 * 60, } @@ -49,7 +49,7 @@ func (o *operator) GetFullName() string { } func (o *operator) GetDependencies(cluster *common.Cluster) ([]string, error) { - return []string{Operator.Name}, nil + return make([]string, 0), nil } // GetClusterValidationID returns cluster validation ID for the Operator diff --git a/internal/operators/osc/operator_test.go b/internal/operators/osc/operator_test.go index f038ac63f4e..eda97039262 100644 --- a/internal/operators/osc/operator_test.go +++ b/internal/operators/osc/operator_test.go @@ -8,7 +8,6 @@ import ( . "github.com/onsi/gomega" "github.com/openshift/assisted-service/internal/common" "github.com/openshift/assisted-service/internal/operators/api" - "github.com/openshift/assisted-service/internal/operators/cnv" "github.com/openshift/assisted-service/models" "github.com/openshift/assisted-service/pkg/conversions" "github.com/sirupsen/logrus" @@ -72,11 +71,6 @@ var _ = Describe("OSC Operator", func() { Entry("min requirements", models.HostRoleMaster, newRequirements(minCpu, minRamMib)), ) - It("should return the dependencies", func() { - preflightRequirements, err := operator.GetPreflightRequirements(context.TODO(), &cluster) - Expect(err).To(BeNil()) - Expect(preflightRequirements.Dependencies).To(Equal([]string{cnv.Operator.Name})) - }) }) Context("Validate host", func() { diff --git a/subsystem/cluster_test.go b/subsystem/cluster_test.go index 6f7357b02cb..3289d43e114 100644 --- a/subsystem/cluster_test.go +++ b/subsystem/cluster_test.go @@ -36,6 +36,7 @@ import ( "github.com/openshift/assisted-service/internal/operators/lvm" "github.com/openshift/assisted-service/internal/operators/mce" "github.com/openshift/assisted-service/internal/operators/mtv" + "github.com/openshift/assisted-service/internal/operators/osc" "github.com/openshift/assisted-service/internal/operators/nodefeaturediscovery" "github.com/openshift/assisted-service/internal/operators/nvidiagpu" "github.com/openshift/assisted-service/internal/operators/odf" @@ -3739,6 +3740,10 @@ var _ = Describe("Preflight Cluster Requirements", func() { CPUCores: mtv.MasterCPU, RAMMib: conversions.GibToMib(mtv.MasterMemory), } + masterOSCRequirements = models.ClusterHostRequirementsDetails{ + CPUCores: osc.MasterCPU, + RAMMib: conversions.GibToMib(osc.MasterMemory), + } workerOpenShiftAIRequirements = models.ClusterHostRequirementsDetails{ CPUCores: 8, RAMMib: conversions.GibToMib(32), @@ -3770,7 +3775,7 @@ var _ = Describe("Preflight Cluster Requirements", func() { }, } Expect(*requirements.Ocp).To(BeEquivalentTo(expectedOcpRequirements)) - Expect(requirements.Operators).To(HaveLen(12)) + Expect(requirements.Operators).To(HaveLen(13)) for _, op := range requirements.Operators { switch op.OperatorName { case lso.Operator.Name: @@ -3790,6 +3795,9 @@ var _ = Describe("Preflight Cluster Requirements", func() { fmt.Sprintf("expected: CPUCores: %d,RAMMib: %d, masterMTVRequirements: CPUCores: %d,RAMMib: %d", op.Requirements.Master.Quantitative.CPUCores, op.Requirements.Master.Quantitative.RAMMib, masterMTVRequirements.CPUCores, masterMTVRequirements.RAMMib)) Expect(*op.Requirements.Worker.Quantitative).To(BeEquivalentTo(workerMTVRequirements), fmt.Sprintf("expected: CPUCores: %d,RAMMib: %d, workerMTVRequirements: CPUCores: %d,RAMMib: %d", op.Requirements.Worker.Quantitative.CPUCores, op.Requirements.Worker.Quantitative.RAMMib, workerMTVRequirements.CPUCores, workerMTVRequirements.RAMMib)) + case osc.Operator.Name: + Expect(*op.Requirements.Master.Quantitative).To(BeEquivalentTo(masterOSCRequirements), + fmt.Sprintf("expected: CPUCores: %d,RAMMib: %d, masterOSCRequirements: CPUCores: %d,RAMMib: %d", op.Requirements.Master.Quantitative.CPUCores, op.Requirements.Master.Quantitative.RAMMib, masterOSCRequirements.CPUCores, masterOSCRequirements.RAMMib)) case nodefeaturediscovery.Operator.Name: continue case nvidiagpu.Operator.Name: diff --git a/subsystem/operators_test.go b/subsystem/operators_test.go index 11b71a5b078..0a440800e9a 100644 --- a/subsystem/operators_test.go +++ b/subsystem/operators_test.go @@ -26,6 +26,7 @@ import ( "github.com/openshift/assisted-service/internal/operators/nvidiagpu" "github.com/openshift/assisted-service/internal/operators/odf" "github.com/openshift/assisted-service/internal/operators/openshiftai" + "github.com/openshift/assisted-service/internal/operators/osc" "github.com/openshift/assisted-service/internal/operators/pipelines" "github.com/openshift/assisted-service/internal/operators/serverless" "github.com/openshift/assisted-service/internal/operators/servicemesh" @@ -50,6 +51,7 @@ var _ = Describe("Operators endpoint tests", func() { lvm.Operator.Name, mce.Operator.Name, mtv.Operator.Name, + osc.Operator.Name, nodefeaturediscovery.Operator.Name, nvidiagpu.Operator.Name, pipelines.Operator.Name,