Skip to content

Commit 9f3fbe3

Browse files
committed
update: monitoring stack only apply if it is managed cluster
- keep managed cluster logic as-is - create redhat-ods-monitoring namespace only in managed if dsic set monitoring to enabled - do not create redhat-ods-monitoring namespace in self-managed any more even monitoring is enabled - remove role rolebinding and servicemonitor in upgrade for self-managed - do not apply role rolebinding networkpoliy and servicemonitor for monitoring in clean install for self-managed Signed-off-by: Wen Zhou <[email protected]>
1 parent 0b4b1f4 commit 9f3fbe3

File tree

4 files changed

+30
-29
lines changed

4 files changed

+30
-29
lines changed

controllers/dscinitialization/dscinitialization_controller.go

+4-15
Original file line numberDiff line numberDiff line change
@@ -234,35 +234,24 @@ func (r *DSCInitializationReconciler) Reconcile(ctx context.Context, req ctrl.Re
234234
if !createUsergroup {
235235
log.Info("DSCI disabled usergroup creation")
236236
} else {
237-
err := r.createUserGroup(ctx, instance, "rhods-admins")
238-
if err != nil {
239-
return reconcile.Result{}, err
240-
}
241-
}
242-
if instance.Spec.Monitoring.ManagementState == operatorv1.Managed {
243-
log.Info("Monitoring enabled, won't apply changes", "cluster", "Self-Managed RHODS Mode")
244-
err = r.configureCommonMonitoring(ctx, instance)
245-
if err != nil {
237+
if err := r.createUserGroup(ctx, instance, "rhods-admins"); err != nil {
246238
return reconcile.Result{}, err
247239
}
248240
}
249241
case cluster.ManagedRhoai:
250242
osdConfigsPath := filepath.Join(deploy.DefaultManifestPath, "osd-configs")
251-
err = deploy.DeployManifestsFromPath(ctx, r.Client, instance, osdConfigsPath, r.ApplicationsNamespace, "osd", true)
252-
if err != nil {
243+
if err = deploy.DeployManifestsFromPath(ctx, r.Client, instance, osdConfigsPath, r.ApplicationsNamespace, "osd", true); err != nil {
253244
log.Error(err, "Failed to apply osd specific configs from manifests", "Manifests path", osdConfigsPath)
254245
r.Recorder.Eventf(instance, corev1.EventTypeWarning, "DSCInitializationReconcileError", "Failed to apply "+osdConfigsPath)
255246

256247
return reconcile.Result{}, err
257248
}
258249
if instance.Spec.Monitoring.ManagementState == operatorv1.Managed {
259250
log.Info("Monitoring enabled in initialization stage", "cluster", "Managed Service Mode")
260-
err := r.configureManagedMonitoring(ctx, instance, "init")
261-
if err != nil {
251+
if err := r.configureManagedMonitoring(ctx, instance, "init"); err != nil {
262252
return reconcile.Result{}, err
263253
}
264-
err = r.configureCommonMonitoring(ctx, instance)
265-
if err != nil {
254+
if err = r.configureCommonMonitoring(ctx, instance); err != nil {
266255
return reconcile.Result{}, err
267256
}
268257
}

controllers/dscinitialization/dscinitialization_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ var _ = Describe("DataScienceCluster initialization", func() {
143143
WithPolling(interval).
144144
Should(BeFalse())
145145
})
146-
It("Should create default monitoring namespace if monitoring enabled", func(ctx context.Context) {
146+
It("Should not create default monitoring namespace even monitoring enabled for non-managed cluster", func(ctx context.Context) {
147147
// when
148148
desiredDsci := createDSCI(operatorv1.Managed, operatorv1.Managed, monitoringNamespace2)
149149
Expect(k8sClient.Create(ctx, desiredDsci)).Should(Succeed())
@@ -159,8 +159,7 @@ var _ = Describe("DataScienceCluster initialization", func() {
159159
WithContext(ctx).
160160
WithTimeout(timeout).
161161
WithPolling(interval).
162-
Should(BeTrue())
163-
Expect(foundMonitoringNamespace.Name).Should(Equal(monitoringNamespace2))
162+
Should(BeFalse())
164163
})
165164
})
166165

controllers/dscinitialization/utils.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func (r *DSCInitializationReconciler) createOdhNamespace(ctx context.Context, ds
8181
return err
8282
}
8383
}
84-
// Create Monitoring Namespace if it is enabled and not exists
85-
if dscInit.Spec.Monitoring.ManagementState == operatorv1.Managed {
84+
// Create Monitoring Namespace if it is enabled and not exists and only for Managed cluster
85+
if dscInit.Spec.Monitoring.ManagementState == operatorv1.Managed && platform == cluster.ManagedRhoai {
8686
foundMonitoringNamespace := &corev1.Namespace{}
8787
monitoringName := dscInit.Spec.Monitoring.Namespace
8888
err := r.Get(ctx, client.ObjectKey{Name: monitoringName}, foundMonitoringNamespace)
@@ -205,18 +205,20 @@ func (r *DSCInitializationReconciler) reconcileDefaultNetworkPolicy(ctx context.
205205
log.Error(err, "error to set networkpolicy in operator namespace", "path", networkpolicyPath)
206206
return err
207207
}
208-
// Deploy networkpolicy for monitoring namespace
209-
err = deploy.DeployManifestsFromPath(ctx, r.Client, dscInit, networkpolicyPath+"/monitoring", dscInit.Spec.Monitoring.Namespace, "networkpolicy", true)
210-
if err != nil {
211-
log.Error(err, "error to set networkpolicy in monitroing namespace", "path", networkpolicyPath)
212-
return err
213-
}
214208
// Deploy networkpolicy for applications namespace
215209
err = deploy.DeployManifestsFromPath(ctx, r.Client, dscInit, networkpolicyPath+"/applications", dscInit.Spec.ApplicationsNamespace, "networkpolicy", true)
216210
if err != nil {
217211
log.Error(err, "error to set networkpolicy in applications namespace", "path", networkpolicyPath)
218212
return err
219213
}
214+
if platform == cluster.ManagedRhoai {
215+
// Deploy networkpolicy for monitoring namespace
216+
err = deploy.DeployManifestsFromPath(ctx, r.Client, dscInit, networkpolicyPath+"/monitoring", dscInit.Spec.Monitoring.Namespace, "networkpolicy", true)
217+
if err != nil {
218+
log.Error(err, "error to set networkpolicy in monitroing namespace", "path", networkpolicyPath)
219+
return err
220+
}
221+
}
220222
} else { // Expected namespace for the given name in ODH
221223
desiredNetworkPolicy := &networkingv1.NetworkPolicy{
222224
TypeMeta: metav1.TypeMeta{

pkg/upgrade/upgrade.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func CleanupExistingResource(ctx context.Context,
218218
oldReleaseVersion cluster.Release,
219219
) error {
220220
var multiErr *multierror.Error
221-
// Special Handling of cleanup of deprecated model monitoring stack
221+
// Special Handling of cleanup of deprecated model monitoring stack on managed
222222
if platform == cluster.ManagedRhoai {
223223
deprecatedDeployments := []string{"rhods-prometheus-operator"}
224224
multiErr = multierror.Append(multiErr, deleteDeprecatedResources(ctx, cli, dscMonitoringNamespace, deprecatedDeployments, &appsv1.DeploymentList{}))
@@ -247,9 +247,20 @@ func CleanupExistingResource(ctx context.Context,
247247
deprecatedServicemonitors := []string{"modelmesh-federated-metrics"}
248248
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedServicemonitors))
249249
}
250+
// Special Handling of cleanup of deprecated SRE monitoring stack on self-managed
251+
if platform == cluster.SelfManagedRhoai {
252+
deprecatedOperatorSM := []string{"rhods-monitor-federation"}
253+
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedOperatorSM))
254+
255+
deprecatedRolebindings := []string{"rhods-prometheus-cluster-monitoring-viewer-binding", "redhat-ods-monitoring"}
256+
multiErr = multierror.Append(multiErr, deleteDeprecatedResources(ctx, cli, dscMonitoringNamespace, deprecatedRolebindings, &rbacv1.RoleBindingList{}))
257+
258+
deprecatedRroles := []string{"redhat-ods-monitoring"}
259+
multiErr = multierror.Append(multiErr, deleteDeprecatedResources(ctx, cli, dscMonitoringNamespace, deprecatedRroles, &rbacv1.RoleList{}))
260+
}
250261
// common logic for both self-managed and managed
251-
deprecatedOperatorSM := []string{"rhods-monitor-federation2"}
252-
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedOperatorSM))
262+
deprecatedOperatorSM2 := []string{"rhods-monitor-federation2"}
263+
multiErr = multierror.Append(multiErr, deleteDeprecatedServiceMonitors(ctx, cli, dscMonitoringNamespace, deprecatedOperatorSM2))
253264

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

0 commit comments

Comments
 (0)