Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Feature support dep1 #7216

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions internal/featuresupport/feature_support_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package featuresupport

import (
"fmt"
"slices"

"github.com/go-openapi/swag"
"github.com/openshift/assisted-service/internal/common"
Expand Down Expand Up @@ -59,6 +60,15 @@ func GetFeatureByID(featureID models.FeatureSupportLevelID) SupportLevelFeature
return featuresList[featureID]
}

func GetFeatureFilter(openshiftVersion string, cpuArchitecture *string, platformType *models.PlatformType, externalPlatformName *string) SupportLevelFilters {
return SupportLevelFilters{
OpenshiftVersion: openshiftVersion,
CPUArchitecture: cpuArchitecture,
PlatformType: platformType,
ExternalPlatformName: externalPlatformName,
}
}

func getFeatureSupportList(features map[models.FeatureSupportLevelID]SupportLevelFeature, filters SupportLevelFilters) models.SupportLevels {
featureSupportList := models.SupportLevels{}

Expand Down Expand Up @@ -92,12 +102,7 @@ func removeEmptySupportLevel(supportLevels models.SupportLevels) {

// GetFeatureSupportList Get features support level list, cpuArchitecture is optional and the default value is x86
func GetFeatureSupportList(openshiftVersion string, cpuArchitecture *string, platformType *models.PlatformType, externalPlatformName *string) models.SupportLevels {
filters := SupportLevelFilters{
OpenshiftVersion: openshiftVersion,
CPUArchitecture: cpuArchitecture,
PlatformType: platformType,
ExternalPlatformName: externalPlatformName,
}
filters := GetFeatureFilter(openshiftVersion, cpuArchitecture, platformType, externalPlatformName)

if cpuArchitecture == nil {
filters.CPUArchitecture = swag.String(common.DefaultCPUArchitecture)
Expand All @@ -116,10 +121,7 @@ func GetFeatureSupportList(openshiftVersion string, cpuArchitecture *string, pla
// IsFeatureAvailable Get the support level of a given feature, cpuArchitecture is optional
// with default value of x86_64
func IsFeatureAvailable(featureId models.FeatureSupportLevelID, openshiftVersion string, cpuArchitecture *string) bool {
filters := SupportLevelFilters{
OpenshiftVersion: openshiftVersion,
CPUArchitecture: cpuArchitecture,
}
filters := GetFeatureFilter(openshiftVersion, cpuArchitecture, nil, nil)

if cpuArchitecture == nil {
filters.CPUArchitecture = swag.String(common.DefaultCPUArchitecture)
Expand Down Expand Up @@ -163,3 +165,18 @@ func isFeaturesCompatible(openshiftVersion, cpuArchitecture string, activatedFea
}
return nil
}

func GetFeatureDependencies(feature models.FeatureSupportLevelID, cluster *common.Cluster) []models.FeatureSupportLevelID {
var featureDependencies []models.FeatureSupportLevelID
dependencies := featuresList[feature].getFeatureDependencies(cluster)
featureDependencies = dependencies
for _, dep := range dependencies {
subDependencies := featuresList[dep].getFeatureDependencies(cluster)
for _, subDependency := range subDependencies {
if !slices.Contains(dependencies, subDependency) {
featureDependencies = append(featureDependencies, subDependency)
}
}
}
return featureDependencies
}
23 changes: 23 additions & 0 deletions internal/featuresupport/features_misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func (feature *SnoFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
return activeLevelNotActive
}

func (feature *SnoFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// CustomManifestFeature
type CustomManifestFeature struct{}

Expand Down Expand Up @@ -101,6 +105,9 @@ func (feature *CustomManifestFeature) getIncompatibleArchitectures(_ *string) *[
func (feature *CustomManifestFeature) getFeatureActiveLevel(_ *common.Cluster, _ *models.InfraEnv, _ *models.V2ClusterUpdateParams, _ *models.InfraEnvUpdateParams) featureActiveLevel {
return activeLeveNotRelevant
}
func (feature *CustomManifestFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// SingleNodeExpansionFeature
type SingleNodeExpansionFeature struct {
Expand Down Expand Up @@ -141,6 +148,9 @@ func (feature *SingleNodeExpansionFeature) getIncompatibleFeatures(string) *[]mo
func (feature *SingleNodeExpansionFeature) getIncompatibleArchitectures(openshiftVersion *string) *[]models.ArchitectureSupportLevelID {
return feature.snoFeature.getIncompatibleArchitectures(openshiftVersion)
}
func (feature *SingleNodeExpansionFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// MinimalIso
type MinimalIso struct{}
Expand Down Expand Up @@ -196,6 +206,9 @@ func (feature *MinimalIso) getFeatureActiveLevel(_ *common.Cluster, infraEnv *mo
}
return activeLevelNotActive
}
func (feature *MinimalIso) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// FullIso
type FullIso struct{}
Expand Down Expand Up @@ -258,6 +271,10 @@ func (feature *FullIso) getFeatureActiveLevel(_ *common.Cluster, infraEnv *model
return activeLevelNotActive
}

func (feature *FullIso) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// Skip MCO reboot
type skipMcoReboot struct{}

Expand Down Expand Up @@ -302,6 +319,9 @@ func (f *skipMcoReboot) getFeatureActiveLevel(cluster *common.Cluster, infraEnv
}
return activeLevelActive
}
func (feature *skipMcoReboot) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// Non-standard HA OCP Control Plane
type NonStandardHAControlPlane struct{}
Expand Down Expand Up @@ -358,3 +378,6 @@ func (f *NonStandardHAControlPlane) getFeatureActiveLevel(cluster *common.Cluste

return activeLevelNotActive
}
func (feature *NonStandardHAControlPlane) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}
29 changes: 29 additions & 0 deletions internal/featuresupport/features_networking.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func (feature *VipAutoAllocFeature) getFeatureActiveLevel(cluster *common.Cluste
return activeLevelNotActive
}

func (feature *VipAutoAllocFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// ClusterManagedNetworkingFeature - DEPRECATED
type ClusterManagedNetworkingFeature struct {
umnFeature UserManagedNetworkingFeature
Expand Down Expand Up @@ -134,6 +138,9 @@ func (feature *ClusterManagedNetworkingFeature) getIncompatibleFeatures(string)
models.FeatureSupportLevelIDEXTERNALPLATFORM,
}
}
func (feature *ClusterManagedNetworkingFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// DualStackFeature
type DualStackFeature struct{}
Expand Down Expand Up @@ -187,6 +194,9 @@ func (feature *DualStackFeature) getIncompatibleFeatures(openshiftVersion string
func (feature *DualStackFeature) getIncompatibleArchitectures(_ *string) *[]models.ArchitectureSupportLevelID {
return nil
}
func (feature *DualStackFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// DualStackVipsFeature
type DualStackVipsFeature struct{}
Expand Down Expand Up @@ -241,6 +251,9 @@ func (feature *DualStackVipsFeature) getIncompatibleFeatures(string) *[]models.F
func (feature *DualStackVipsFeature) getIncompatibleArchitectures(_ *string) *[]models.ArchitectureSupportLevelID {
return nil
}
func (feature *DualStackVipsFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// UserManagedNetworkingFeature
type UserManagedNetworkingFeature struct{}
Expand Down Expand Up @@ -301,6 +314,9 @@ func (feature *UserManagedNetworkingFeature) getFeatureActiveLevel(cluster *comm
}
return activeLevelNotActive
}
func (feature *UserManagedNetworkingFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// PlatformManagedNetworkingFeature
type PlatformManagedNetworkingFeature struct{}
Expand Down Expand Up @@ -357,6 +373,10 @@ func (feature *PlatformManagedNetworkingFeature) getFeatureActiveLevel(cluster *
return activeLevelNotActive
}

func (feature *PlatformManagedNetworkingFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// SDNNetworkTypeFeature
type SDNNetworkTypeFeature struct{}

Expand Down Expand Up @@ -410,6 +430,9 @@ func (feature *SDNNetworkTypeFeature) Validate(cluster *common.Cluster, updatePa
func (feature *SDNNetworkTypeFeature) hasValidOpenshiftVersion(openshiftVersion string) bool {
return openshiftVersionLessThan("4.15", openshiftVersion)
}
func (feature *SDNNetworkTypeFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// OVNNetworkTypeFeature
type OVNNetworkTypeFeature struct{}
Expand Down Expand Up @@ -470,6 +493,9 @@ func openshiftVersionLessThan(targetVersion, openshiftVersion string) bool {

return openshiftVersion == "" || err == nil && isAvailable
}
func (feature *OVNNetworkTypeFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// UserManagedLoadBalancerFeature
type UserManagedLoadBalancerFeature struct{}
Expand Down Expand Up @@ -526,3 +552,6 @@ func (feature *UserManagedLoadBalancerFeature) getFeatureActiveLevel(cluster *co

return activeLevelNotActive
}
func (feature *UserManagedLoadBalancerFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}
68 changes: 68 additions & 0 deletions internal/featuresupport/features_olm_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package featuresupport
import (
"github.com/go-openapi/swag"
"github.com/openshift/assisted-service/internal/common"
"github.com/openshift/assisted-service/internal/operators/lvm"
"github.com/openshift/assisted-service/models"
"github.com/thoas/go-funk"
)
Expand Down Expand Up @@ -101,6 +102,9 @@ func (feature *LvmFeature) getIncompatibleArchitectures(_ *string) *[]models.Arc
models.ArchitectureSupportLevelIDPPC64LEARCHITECTURE,
}
}
func (feature *LvmFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// OdfFeature
type OdfFeature struct{}
Expand Down Expand Up @@ -144,6 +148,9 @@ func (feature *OdfFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *OdfFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// CnvFeature
type CnvFeature struct{}
Expand Down Expand Up @@ -201,6 +208,32 @@ func (feature *CnvFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *CnvFeature) getFeatureDependencies(cluster *common.Cluster) []models.FeatureSupportLevelID {

// Disable lso for ARM deployment as it's not supported
// to allow CNV ARM operator
if cluster.CPUArchitecture == common.ARM64CPUArchitecture || cluster.CPUArchitecture == common.MultiCPUArchitecture {
return []models.FeatureSupportLevelID{}
}

if cluster.OpenshiftVersion == "" {
return []models.FeatureSupportLevelID{
models.FeatureSupportLevelIDLSO,
}
}

// SNO
if common.IsSingleNodeCluster(cluster) {
if isGreaterOrEqual, _ := common.BaseVersionGreaterOrEqual(lvm.LvmsMinOpenshiftVersion4_12, cluster.OpenshiftVersion); isGreaterOrEqual {
return []models.FeatureSupportLevelID{
models.FeatureSupportLevelIDLVM,
}
}
}
return []models.FeatureSupportLevelID{
models.FeatureSupportLevelIDLSO,
}
}

// LsoFeature
type LsoFeature struct{}
Expand Down Expand Up @@ -241,6 +274,9 @@ func (feature *LsoFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *LsoFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// MceFeature
type MceFeature struct{}
Expand Down Expand Up @@ -290,6 +326,9 @@ func (feature *MceFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *MceFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// MtvFeature
type MtvFeature struct{}
Expand Down Expand Up @@ -344,6 +383,11 @@ func (feature *MtvFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *MtvFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{
models.FeatureSupportLevelIDCNV,
}
}

// NodeFeatureDiscoveryFeature describes the support for the node feature discovery operator.
type NodeFeatureDiscoveryFeature struct{}
Expand Down Expand Up @@ -389,6 +433,9 @@ func (f *NodeFeatureDiscoveryFeature) getFeatureActiveLevel(cluster *common.Clus
}
return activeLevelNotActive
}
func (feature *NodeFeatureDiscoveryFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// NvidiaGPUFeature describes the support for the NVIDIA GPU operator.
type NvidiaGPUFeature struct{}
Expand Down Expand Up @@ -431,6 +478,9 @@ func (f *NvidiaGPUFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *NvidiaGPUFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// PipelinesFeature describes the support for the pipelines operator.
type PipelinesFeature struct{}
Expand Down Expand Up @@ -469,6 +519,9 @@ func (f *PipelinesFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *PipelinesFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// ServiceMeshFeature describes the support for the service mesh operator.
type ServiceMeshFeature struct{}
Expand Down Expand Up @@ -507,6 +560,9 @@ func (f *ServiceMeshFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *m
}
return activeLevelNotActive
}
func (feature *ServiceMeshFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// ServerLessFeature describes the support for the serverless operator.
type ServerLessFeature struct{}
Expand Down Expand Up @@ -545,6 +601,9 @@ func (f *ServerLessFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mo
}
return activeLevelNotActive
}
func (feature *ServerLessFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// OpenShiftAPIFeature describes the support for the OpenShift API operator.
type OpenShiftAIFeature struct{}
Expand Down Expand Up @@ -596,6 +655,9 @@ func (f *OpenShiftAIFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *m
}
return activeLevelNotActive
}
func (feature *OpenShiftAIFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// AuthorinoFeature describes the support for the Authorino operator.
type AuthorinoFeature struct{}
Expand Down Expand Up @@ -632,6 +694,9 @@ func (f *AuthorinoFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *AuthorinoFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}

// OscFeature
type OscFeature struct{}
Expand Down Expand Up @@ -686,3 +751,6 @@ func (feature *OscFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *mod
}
return activeLevelNotActive
}
func (feature *OscFeature) getFeatureDependencies(_ *common.Cluster) []models.FeatureSupportLevelID {
return []models.FeatureSupportLevelID{}
}
Loading