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 Mar 4, 2024
1 parent 181ecdc commit 3b9adf5
Show file tree
Hide file tree
Showing 2 changed files with 776 additions and 1 deletion.
34 changes: 33 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,17 @@ func (mgr *Manager) GetRequirementsBreakdownForHostInCluster(ctx context.Context
return requirements, nil
}

func compareOperatorName(operatorName string) func(operator *models.MonitoredOperator) bool {
return func(operator *models.MonitoredOperator) bool {
return operatorName == operator.Name
}
}
func hasMCEWithStorage(operators []*models.MonitoredOperator) bool {
return funk.Contains(operators, compareOperatorName(mce.Operator.Name)) &&
(funk.Contains(operators, compareOperatorName(lvm.Operator.Name)) ||
funk.Contains(operators, compareOperatorName(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 +160,26 @@ func (mgr *Manager) GenerateManifests(ctx context.Context, cluster *common.Clust
customManifests = append(customManifests, Manifest{Name: clusterOperator.Name, Content: base64.StdEncoding.EncodeToString(manifest)})
}
}

ops := []string{}
for _, o := range cluster.MonitoredOperators {
ops = append(ops, o.Name)
}
if hasMCEWithStorage(cluster.MonitoredOperators) && false {
mgr.log.WithFields(logrus.Fields{
"operators": ops,
}).Info("Generating AgentServiceConfig...")
agentServiceConfigYaml, err := mce.GetAgentServiceConfigWithPVCManifest()
if err != nil {
return err
}
if err = mgr.createManifests(ctx, cluster, "99-agentserviceconfig.yaml", agentServiceConfigYaml, models.ManifestFolderOpenshift); err != nil {
return err
}
} else {
mgr.log.WithFields(logrus.Fields{
"operators": ops,
}).Info("NOT Generating AgentServiceConfig...")
}
if len(customManifests) > 0 {
content, err := json.Marshal(customManifests)
if err != nil {
Expand Down

0 comments on commit 3b9adf5

Please sign in to comment.