Skip to content

Commit

Permalink
Hub metrics collector feature (#1316)
Browse files Browse the repository at this point in the history
* install Metrics Without Addon

Signed-off-by: clyang82 <[email protected]>

* install Metrics Without Addon

Signed-off-by: clyang82 <[email protected]>

* install Metrics Without Addon

Signed-off-by: clyang82 <[email protected]>

* modify endpoint operator

Signed-off-by: clyang82 <[email protected]>

* modify endpoint operator

Signed-off-by: clyang82 <[email protected]>

* check for global hub operator and prevent observability from installing in the spokes

Signed-off-by: Coleen Iona Quadros <[email protected]>

---------

Signed-off-by: clyang82 <[email protected]>
Signed-off-by: Coleen Iona Quadros <[email protected]>
Co-authored-by: clyang82 <[email protected]>
  • Loading branch information
coleenquadros and clyang82 authored Feb 8, 2024
1 parent 3953cd8 commit c47191c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,21 @@ func (r *PlacementRuleReconciler) Reconcile(ctx context.Context, req ctrl.Reques
return ctrl.Result{}, nil
}

//Check for MulticlusterGlobalHub CRD
mcghCrdExists := r.CRDMap[config.MCGHCrdName]
//if Multicluster Global hub exists we block metrics-collector creation in spokes
if mcghCrdExists {
mco.Spec.ObservabilityAddonSpec.EnableMetrics = false
}

if !deleteAll && !mco.Spec.ObservabilityAddonSpec.EnableMetrics {
reqLogger.Info("EnableMetrics is set to false. Delete Observability addons")
deleteAll = true
}

// check if the MCH CRD exists
mchCrdExists := r.CRDMap[config.MCHCrdName]
// requeue after 10 seconds if the mch crd exists and image image manifests map is empty
// requeue after 10 seconds if the mch crd exists and image manifests map is empty
if mchCrdExists && len(config.GetImageManifests()) == 0 {
// if the mch CR is not ready, then requeue the request after 10s
return ctrl.Result{RequeueAfter: 10 * time.Second}, nil
Expand Down
7 changes: 7 additions & 0 deletions operators/multiclusterobservability/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,17 @@ func main() {
os.Exit(1)
}

mcghCrdExists, err := operatorsutil.CheckCRDExist(crdClient, config.MCGHCrdName)
if err != nil {
setupLog.Error(err, "")
os.Exit(1)
}

crdMaps := map[string]bool{
config.MCHCrdName: mchCrdExists,
config.StorageVersionMigrationCrdName: svmCrdExists,
config.IngressControllerCRD: ingressCtlCrdExists,
config.MCGHCrdName: mcghCrdExists,
}

if err = (&mcoctrl.MultiClusterObservabilityReconciler{
Expand Down
1 change: 1 addition & 0 deletions operators/multiclusterobservability/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ const (
IngressControllerCRD = "ingresscontrollers.operator.openshift.io"
MCHCrdName = "multiclusterhubs.operator.open-cluster-management.io"
MCOCrdName = "multiclusterobservabilities.observability.open-cluster-management.io"
MCGHCrdName = "multiclusterglobalhubs.operator.open-cluster-management.io"
StorageVersionMigrationCrdName = "storageversionmigrations.migration.k8s.io"
)

Expand Down

0 comments on commit c47191c

Please sign in to comment.