Skip to content

Commit

Permalink
MGMT-17080: enable infrastructure operator when MCE and storage opera…
Browse files Browse the repository at this point in the history
…tors are selected

Signed-off-by: Riccardo Piccoli <rpiccoli@redhat.com>
  • Loading branch information
rccrdpccl committed Feb 28, 2024
1 parent 181ecdc commit 23a1313
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/operators/manager.go
Expand Up @@ -15,6 +15,8 @@ import (
manifestsapi "github.com/openshift/assisted-service/internal/manifests/api"
"github.com/openshift/assisted-service/internal/operators/api"
"github.com/openshift/assisted-service/internal/operators/lvm"
"github.com/openshift/assisted-service/internal/operators/mce"
"github.com/openshift/assisted-service/internal/operators/odf"
"github.com/openshift/assisted-service/models"
logutil "github.com/openshift/assisted-service/pkg/log"
"github.com/openshift/assisted-service/pkg/s3wrapper"
Expand Down Expand Up @@ -120,6 +122,10 @@ func (mgr *Manager) GetRequirementsBreakdownForHostInCluster(ctx context.Context
return requirements, nil
}

func HasMCEWithStorage(operators []*models.MonitoredOperator) bool {
return funk.Contains(operators, mce.Operator.Name) && (funk.Contains(operators, lvm.Operator.Name) || funk.Contains(operators, odf.Operator.Name))
}

// GenerateManifests generates manifests for all enabled operators.
// Returns map assigning manifest content to its desired file name
func (mgr *Manager) GenerateManifests(ctx context.Context, cluster *common.Cluster) error {
Expand Down Expand Up @@ -147,7 +153,15 @@ func (mgr *Manager) GenerateManifests(ctx context.Context, cluster *common.Clust
customManifests = append(customManifests, Manifest{Name: clusterOperator.Name, Content: base64.StdEncoding.EncodeToString(manifest)})
}
}

if HasMCEWithStorage(cluster.MonitoredOperators) {
agentServiceConfigYaml, err := mce.GetAgentServiceConfigWithPVCManifest()
if err != nil {
return err
}
if err = mgr.createCustomManifest(ctx, cluster, string(agentServiceConfigYaml)); err != nil {
return err
}
}
if len(customManifests) > 0 {
content, err := json.Marshal(customManifests)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions internal/operators/mce/manifest.go
Expand Up @@ -3,6 +3,9 @@ package mce
import (
"bytes"
"text/template"

aiv1beta1 "github.com/openshift/assisted-service/api/v1beta1"
"sigs.k8s.io/yaml"
)

// Manifests returns manifests needed to deploy MCE.
Expand Down Expand Up @@ -34,6 +37,12 @@ func Manifests() (openshiftManifests map[string][]byte, customManifests []byte,
return openshiftManifests, mceManifest, nil
}

func GetAgentServiceConfigWithPVCManifest() ([]byte, error) {
// generate AgentServiceConfig with default values
agentServiceConfig := &aiv1beta1.AgentServiceConfig{}
return yaml.Marshal(agentServiceConfig)
}

func getSubscription() ([]byte, error) {
data := map[string]string{
"OPERATOR_NAMESPACE": Operator.Namespace,
Expand Down

0 comments on commit 23a1313

Please sign in to comment.