Skip to content

Commit

Permalink
Add osc operator
Browse files Browse the repository at this point in the history
Signed-off-by: xiangchun Fu <xfu@redhat.com>
  • Loading branch information
xiangchunfu committed Nov 24, 2024
1 parent d8cdc34 commit b5eafcd
Show file tree
Hide file tree
Showing 25 changed files with 720 additions and 10 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.

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

1 change: 1 addition & 0 deletions internal/cluster/statemachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ func NewClusterStateMachine(th TransitionHandler) stateswitch.StateMachine {
If(IsLvmRequirementsSatisfied),
If(IsMceRequirementsSatisfied),
If(IsMtvRequirementsSatisfied),
If(IsOscRequirementsSatisfied),
If(isNetworkTypeValid),
If(NetworksSameAddressFamilies),
If(IsNodeFeatureDiscoveryRequirementsSatisfied),
Expand Down
2 changes: 2 additions & 0 deletions internal/cluster/validation_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
IsLvmRequirementsSatisfied = ValidationID(models.ClusterValidationIDLvmRequirementsSatisfied)
IsMceRequirementsSatisfied = ValidationID(models.ClusterValidationIDMceRequirementsSatisfied)
IsMtvRequirementsSatisfied = ValidationID(models.ClusterValidationIDMtvRequirementsSatisfied)
IsOscRequirementsSatisfied = ValidationID(models.ClusterValidationIDOscRequirementsSatisfied)
PlatformRequirementsSatisfied = ValidationID(models.ClusterValidationIDPlatformRequirementsSatisfied)
IsNodeFeatureDiscoveryRequirementsSatisfied = ValidationID(models.ClusterValidationIDNodeFeatureDiscoveryRequirementsSatisfied)
IsNvidiaGPURequirementsSatisfied = ValidationID(models.ClusterValidationIDNvidiaGpuRequirementsSatisfied)
Expand All @@ -59,6 +60,7 @@ func (v ValidationID) Category() (string, error) {
IsLvmRequirementsSatisfied,
IsMceRequirementsSatisfied,
IsMtvRequirementsSatisfied,
IsOscRequirementsSatisfied,
IsNodeFeatureDiscoveryRequirementsSatisfied,
IsNvidiaGPURequirementsSatisfied,
IsPipelinesRequirementsSatisfied,
Expand Down
1 change: 1 addition & 0 deletions internal/featuresupport/feature_support_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +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.FeatureSupportLevelIDNODEFEATUREDISCOVERY: (&NodeFeatureDiscoveryFeature{}).New(),
models.FeatureSupportLevelIDNVIDIAGPU: (&NvidiaGPUFeature{}).New(),
models.FeatureSupportLevelIDPIPELINES: (&PipelinesFeature{}).New(),
Expand Down
54 changes: 54 additions & 0 deletions internal/featuresupport/features_olm_operators.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,3 +590,57 @@ func (f *OpenShiftAIFeature) getFeatureActiveLevel(cluster *common.Cluster, _ *m
}
return activeLevelNotActive
}

// OSCFeature
type OSCFeature struct{}

func (feature *OSCFeature) New() SupportLevelFeature {
return &OSCFeature{}
}

func (feature *OSCFeature) getId() models.FeatureSupportLevelID {
return models.FeatureSupportLevelIDOSC
}

func (feature *OSCFeature) GetName() string {
return "OpenShift Sandboxed Containers"
}

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) {
return models.SupportLevelUnavailable
}

if isNotSupported, err := common.BaseVersionLessThan("4.17", filters.OpenshiftVersion); isNotSupported || err != nil {
return models.SupportLevelUnavailable
}

return models.SupportLevelSupported
}

func (feature *OSCFeature) getIncompatibleArchitectures(_ *string) *[]models.ArchitectureSupportLevelID {
incompatibleArchitecture := []models.ArchitectureSupportLevelID{
models.ArchitectureSupportLevelIDARM64ARCHITECTURE,
models.ArchitectureSupportLevelIDS390XARCHITECTURE,
models.ArchitectureSupportLevelIDPPC64LEARCHITECTURE,
}
return &incompatibleArchitecture
}

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) {
return activeLevelActive
}
return activeLevelNotActive
}
2 changes: 2 additions & 0 deletions internal/featuresupport/features_platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ func (feature *NutanixIntegrationFeature) getIncompatibleFeatures(string) *[]mod
models.FeatureSupportLevelIDCNV,
models.FeatureSupportLevelIDPLATFORMMANAGEDNETWORKING,
models.FeatureSupportLevelIDMTV,
models.FeatureSupportLevelIDOSC,
}
}

Expand Down Expand Up @@ -236,6 +237,7 @@ func (feature *VsphereIntegrationFeature) getIncompatibleFeatures(openshiftVersi
models.FeatureSupportLevelIDPLATFORMMANAGEDNETWORKING,
models.FeatureSupportLevelIDCNV,
models.FeatureSupportLevelIDMTV,
models.FeatureSupportLevelIDOSC,
}

if isNotSupported, err := common.BaseVersionLessThan("4.13", openshiftVersion); isNotSupported || err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/host/statemachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,7 @@ func NewHostStateMachine(sm stateswitch.StateMachine, th TransitionHandler) stat
If(AreLvmRequirementsSatisfied),
If(AreMceRequirementsSatisfied),
If(AreMtvRequirementsSatisfied),
If(AreOscRequirementsSatisfied),
If(HasSufficientNetworkLatencyRequirementForRole),
If(HasSufficientPacketLossRequirementForRole),
If(HasDefaultRoute),
Expand Down
4 changes: 3 additions & 1 deletion internal/host/validation_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const (
AreLvmRequirementsSatisfied = validationID(models.HostValidationIDLvmRequirementsSatisfied)
AreMceRequirementsSatisfied = validationID(models.HostValidationIDMceRequirementsSatisfied)
AreMtvRequirementsSatisfied = validationID(models.HostValidationIDMtvRequirementsSatisfied)
AreOscRequirementsSatisfied = validationID(models.HostValidationIDOscRequirementsSatisfied)
SufficientOrUnknownInstallationDiskSpeed = validationID(models.HostValidationIDSufficientInstallationDiskSpeed)
HasSufficientNetworkLatencyRequirementForRole = validationID(models.HostValidationIDSufficientNetworkLatencyRequirementForRole)
HasSufficientPacketLossRequirementForRole = validationID(models.HostValidationIDSufficientPacketLossRequirementForRole)
Expand Down Expand Up @@ -112,7 +113,8 @@ func (v validationID) category() (string, error) {
ArePipelinesRequirementsSatisfied,
AreServiceMeshRequirementsSatisfied,
AreServerLessRequirementsSatisfied,
AreOpenShiftAIRequirementsSatisfied:
AreOpenShiftAIRequirementsSatisfied,
AreOscRequirementsSatisfied:
return "operators", nil
}
return "", common.NewApiError(http.StatusInternalServerError, errors.Errorf("Unexpected validation id %s", string(v)))
Expand Down
2 changes: 2 additions & 0 deletions internal/operators/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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"
Expand Down Expand Up @@ -54,6 +55,7 @@ func NewManager(log logrus.FieldLogger, manifestAPI manifestsapi.ManifestsAPI, o
servicemesh.NewServiceMeshOperator(log),
serverless.NewServerLessOperator(log),
openshiftai.NewOpenShiftAIOperator(log),
osc.NewOscOperator(log),
)
}

Expand Down
25 changes: 25 additions & 0 deletions internal/operators/osc/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package osc

const (
Name = "osc"
FullName = "OpenShift Sandboxed Containers"
Namespace = "openshift-sandboxed-containers-operator"
Subscription = "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"
// 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 {
OscCPUPerHost int64 `envconfig:"Osc_CPU_PER_HOST" default:"1"`
OscMemoryPerHostMiB int64 `envconfig:"Osc_MEMORY_PER_HOST_MIB" default:"1024"`
}
Loading

0 comments on commit b5eafcd

Please sign in to comment.