Skip to content

Commit

Permalink
chore: cleanup Monitoring's initialize action (opendatahub-io#1542)
Browse files Browse the repository at this point in the history
The Monitoring controller is initialized only when the platform is
managed, hence there's no need to conditionally add manifests
  • Loading branch information
lburgazzoli authored Jan 22, 2025
1 parent 5321b8c commit 21eba1b
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions controllers/services/monitoring/monitoring_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"

componentApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/components/v1alpha1"
dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1"
serviceApi "github.com/opendatahub-io/opendatahub-operator/v2/apis/services/v1alpha1"
"github.com/opendatahub-io/opendatahub-operator/v2/controllers/status"
"github.com/opendatahub-io/opendatahub-operator/v2/pkg/cluster"
cr "github.com/opendatahub-io/opendatahub-operator/v2/pkg/componentsregistry"
odhtypes "github.com/opendatahub-io/opendatahub-operator/v2/pkg/controller/types"
odhdeploy "github.com/opendatahub-io/opendatahub-operator/v2/pkg/deploy"
Expand All @@ -38,22 +36,13 @@ var componentRules = map[string]string{
}

// initialize handles all pre-deployment configurations.
func initialize(ctx context.Context, rr *odhtypes.ReconciliationRequest) error {
log := logf.FromContext(ctx)
// Only handle manifests setup and initial configurations
platform := rr.Release.Name
switch platform {
case cluster.ManagedRhoai:
// Only set prometheus configmap path
rr.Manifests = []odhtypes.ManifestInfo{
{
Path: odhdeploy.DefaultManifestPath,
ContextDir: "monitoring/prometheus/apps",
},
}

default:
log.V(3).Info("Monitoring enabled, won't apply changes in this mode", "cluster", platform)
func initialize(_ context.Context, rr *odhtypes.ReconciliationRequest) error {
// Only set prometheus configmap path
rr.Manifests = []odhtypes.ManifestInfo{
{
Path: odhdeploy.DefaultManifestPath,
ContextDir: "monitoring/prometheus/apps",
},
}

return nil
Expand Down

0 comments on commit 21eba1b

Please sign in to comment.