Skip to content

Commit

Permalink
update: monitoring stack only apply if it is managed cluster
Browse files Browse the repository at this point in the history
- keep managed cluster logic as-is
- create redhat-ods-monitoring namespace in self-managed if dsic set monitoring to enabled
- remove role rolebinding and servicemonitor in upgrade for self-managed
- do not apply role rolebinding and servicemonitor in clean install for self-managed

Signed-off-by: Wen Zhou <[email protected]>
  • Loading branch information
zdtsw committed Oct 28, 2024
1 parent c0e0709 commit 5bae7c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
19 changes: 4 additions & 15 deletions controllers/dscinitialization/dscinitialization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,35 +234,24 @@ func (r *DSCInitializationReconciler) Reconcile(ctx context.Context, req ctrl.Re
if !createUsergroup {
log.Info("DSCI disabled usergroup creation")
} else {
err := r.createUserGroup(ctx, instance, "rhods-admins")
if err != nil {
return reconcile.Result{}, err
}
}
if instance.Spec.Monitoring.ManagementState == operatorv1.Managed {
log.Info("Monitoring enabled, won't apply changes", "cluster", "Self-Managed RHODS Mode")
err = r.configureCommonMonitoring(ctx, instance)
if err != nil {
if err := r.createUserGroup(ctx, instance, "rhods-admins"); err != nil {
return reconcile.Result{}, err
}
}
case cluster.ManagedRhoai:
osdConfigsPath := filepath.Join(deploy.DefaultManifestPath, "osd-configs")
err = deploy.DeployManifestsFromPath(ctx, r.Client, instance, osdConfigsPath, r.ApplicationsNamespace, "osd", true)
if err != nil {
if err = deploy.DeployManifestsFromPath(ctx, r.Client, instance, osdConfigsPath, r.ApplicationsNamespace, "osd", true); err != nil {
log.Error(err, "Failed to apply osd specific configs from manifests", "Manifests path", osdConfigsPath)
r.Recorder.Eventf(instance, corev1.EventTypeWarning, "DSCInitializationReconcileError", "Failed to apply "+osdConfigsPath)

return reconcile.Result{}, err
}
if instance.Spec.Monitoring.ManagementState == operatorv1.Managed {
log.Info("Monitoring enabled in initialization stage", "cluster", "Managed Service Mode")
err := r.configureManagedMonitoring(ctx, instance, "init")
if err != nil {
if err := r.configureManagedMonitoring(ctx, instance, "init"); err != nil {
return reconcile.Result{}, err
}
err = r.configureCommonMonitoring(ctx, instance)
if err != nil {
if err = r.configureCommonMonitoring(ctx, instance); err != nil {
return reconcile.Result{}, err
}
}
Expand Down
17 changes: 14 additions & 3 deletions pkg/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func CleanupExistingResource(ctx context.Context,
oldReleaseVersion cluster.Release,
) error {
var multiErr *multierror.Error
// Special Handling of cleanup of deprecated model monitoring stack
// Special Handling of cleanup of deprecated model monitoring stack on managed
if platform == cluster.ManagedRhoai {
deprecatedDeployments := []string{"rhods-prometheus-operator"}
multiErr = multierror.Append(multiErr, deleteDeprecatedResources(ctx, cli, dscMonitoringNamespace, deprecatedDeployments, &appsv1.DeploymentList{}))
Expand Down Expand Up @@ -245,9 +245,20 @@ func CleanupExistingResource(ctx context.Context,
deprecatedServicemonitors := []string{"modelmesh-federated-metrics"}
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedServicemonitors))
}
// Special Handling of cleanup of deprecated SRE monitoring stack on self-managed
if platform == cluster.SelfManagedRhoai {
deprecatedOperatorSM := []string{"rrhods-monitor-federation"}
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedOperatorSM))

deprecatedRolebindings := []string{"rhods-prometheus-cluster-monitoring-viewer-binding", "redhat-ods-monitoring"}
multiErr = multierror.Append(multiErr, deleteDeprecatedResources(ctx, cli, dscMonitoringNamespace, deprecatedRolebindings, &rbacv1.RoleBindingList{}))

deprecatedRroles := []string{"redhat-ods-monitoring"}
multiErr = multierror.Append(multiErr, deleteDeprecatedResources(ctx, cli, dscMonitoringNamespace, deprecatedRroles, &rbacv1.RoleList{}))
}
// common logic for both self-managed and managed
deprecatedOperatorSM := []string{"rhods-monitor-federation2"}
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedOperatorSM))
deprecatedOperatorSM2 := []string{"rhods-monitor-federation2"}
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedOperatorSM2))

// Remove deprecated opendatahub namespace(previously owned by kuberay and Kueue)
multiErr = multierror.Append(multiErr, deleteDeprecatedNamespace(ctx, cli, "opendatahub"))
Expand Down

0 comments on commit 5bae7c6

Please sign in to comment.