Skip to content

Commit 8750214

Browse files
authored
Disable cluster monitoring for Velero and remove ServiceMonitor from the Velero deployment. (#1081)
First change to remove cluster monitoring of OADP that will be replaced by the user workload monitoring (UWM). Related Issues: #769 https://issues.redhat.com/browse/OADP-1887 https://issues.redhat.com/browse/OADP-661 The openshift-adp-velero-metrics-svc is left to easy process of enabling UWM. Once UWM is enabled, it will require setting up ServiceMonitor and configuring alerts or dashboards that are crucial for a particular use-case. Enablement of user workload monitoring with additional documentation is not part of this PR to easilly re-add the cluster monitoring in the future by reverting this change. Signed-off-by: Michal Pryc <[email protected]>
1 parent 9138f8d commit 8750214

12 files changed

+0
-292
lines changed

bundle/manifests/oadp-operator.clusterserviceversion.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ metadata:
155155
description: OADP (OpenShift API for Data Protection) operator sets up and installs
156156
Data Protection Applications on the OpenShift platform.
157157
olm.skipRange: '>=0.0.0 <99.0.0'
158-
operatorframework.io/cluster-monitoring: "true"
159158
operatorframework.io/suggested-namespace: openshift-adp
160159
operators.openshift.io/infrastructure-features: '["Disconnected"]'
161160
operators.openshift.io/valid-subscription: '["OpenShift Container Platform", "OpenShift

bundle/manifests/oadp-operator_monitoring.coreos.com_v1_prometheusrule.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

config/manager/manager.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ kind: Namespace
33
metadata:
44
labels:
55
control-plane: controller-manager
6-
openshift.io/cluster-monitoring: "true"
76
name: system
87
---
98
apiVersion: apps/v1

config/manifests/bases/oadp-operator.clusterserviceversion.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ metadata:
1010
description: OADP (OpenShift API for Data Protection) operator sets up and installs
1111
Data Protection Applications on the OpenShift platform.
1212
olm.skipRange: '>=0.0.0 <99.0.0'
13-
operatorframework.io/cluster-monitoring: "true"
1413
operatorframework.io/suggested-namespace: openshift-adp
1514
operators.openshift.io/infrastructure-features: '["Disconnected"]'
1615
operators.openshift.io/valid-subscription: '["OpenShift Container Platform", "OpenShift

config/manifests/kustomization.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ resources:
66
- ../samples
77
- ../scorecard
88
- ../velero
9-
- ../prometheus
109

1110
# [WEBHOOK] To enable webhooks, uncomment all the sections with [WEBHOOK] prefix.
1211
# Do NOT uncomment sections with prefix [CERTMANAGER], as OLM does not support cert-manager.

config/prometheus/kustomization.yaml

Lines changed: 0 additions & 3 deletions
This file was deleted.

config/prometheus/monitor.yaml

Lines changed: 0 additions & 20 deletions
This file was deleted.

config/prometheus/oadp-metrics-recording-rule.yaml

Lines changed: 0 additions & 12 deletions
This file was deleted.

controllers/dpa_controller.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func (r *DPAReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.R
102102
r.ReconcileVolumeSnapshotLocations,
103103
r.ReconcileVeleroDeployment,
104104
r.ReconcileResticDaemonset,
105-
r.ReconcileVeleroServiceMonitor,
106105
r.ReconcileVeleroMetricsSVC,
107106
r.ReconcileDataMoverController,
108107
r.ReconcileDataMoverResticSecret,

controllers/monitor.go

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,105 +5,12 @@ import (
55

66
"github.com/go-logr/logr"
77
oadpv1alpha1 "github.com/openshift/oadp-operator/api/v1alpha1"
8-
monitor "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
98
corev1 "k8s.io/api/core/v1"
109
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1110
"k8s.io/apimachinery/pkg/util/intstr"
1211
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1312
)
1413

15-
func (r *DPAReconciler) ReconcileVeleroServiceMonitor(log logr.Logger) (bool, error) {
16-
17-
dpa := oadpv1alpha1.DataProtectionApplication{}
18-
if err := r.Get(r.Context, r.NamespacedName, &dpa); err != nil {
19-
return false, err
20-
}
21-
22-
serviceMonitor := &monitor.ServiceMonitor{
23-
ObjectMeta: metav1.ObjectMeta{
24-
Name: "openshift-adp-velero-metrics-sm",
25-
Namespace: r.NamespacedName.Namespace,
26-
},
27-
}
28-
29-
op, err := controllerutil.CreateOrPatch(r.Context, r.Client, serviceMonitor, func() error {
30-
31-
if serviceMonitor.ObjectMeta.CreationTimestamp.IsZero() {
32-
serviceMonitor.Spec.Selector = metav1.LabelSelector{
33-
MatchLabels: getDpaAppLabels(&dpa),
34-
}
35-
}
36-
37-
// update service monitor
38-
return r.buildVeleroServiceMonitor(serviceMonitor, &dpa)
39-
})
40-
41-
if err != nil {
42-
return false, err
43-
}
44-
45-
//TODO: Review service monitor status and report errors and conditions
46-
47-
if op == controllerutil.OperationResultCreated || op == controllerutil.OperationResultUpdated {
48-
// Trigger event to indicate service monitor was created or updated
49-
r.EventRecorder.Event(serviceMonitor,
50-
corev1.EventTypeNormal,
51-
"VeleroServiceMonitorReconciled",
52-
fmt.Sprintf("performed %s on dpa service monitor %s/%s", op, serviceMonitor.Namespace, serviceMonitor.Name),
53-
)
54-
}
55-
return true, nil
56-
}
57-
58-
func (r *DPAReconciler) buildVeleroServiceMonitor(serviceMonitor *monitor.ServiceMonitor, dpa *oadpv1alpha1.DataProtectionApplication) error {
59-
60-
if dpa == nil {
61-
return fmt.Errorf("dpa CR cannot be nil")
62-
}
63-
64-
if serviceMonitor == nil {
65-
return fmt.Errorf("service monitor cannot be nil")
66-
}
67-
68-
// Setting controller owner reference on the service monitor
69-
err := controllerutil.SetControllerReference(dpa, serviceMonitor, r.Scheme)
70-
if err != nil {
71-
return err
72-
}
73-
74-
serviceMonitor.Spec.Selector = metav1.LabelSelector{
75-
MatchLabels: getDpaAppLabels(dpa),
76-
}
77-
78-
serviceMonitor.Labels = getDpaAppLabels(dpa)
79-
80-
serviceMonitor.Spec.Endpoints = []monitor.Endpoint{
81-
{
82-
Interval: "30s",
83-
Port: "monitoring",
84-
MetricRelabelConfigs: []*monitor.RelabelConfig{
85-
{
86-
Action: "keep",
87-
Regex: ("velero_backup_total|velero_restore_total"),
88-
SourceLabels: []string{
89-
"__name__",
90-
},
91-
},
92-
},
93-
},
94-
}
95-
96-
//serviceMonitor.Spec.JobLabel = "app"
97-
98-
serviceMonitor.Spec.NamespaceSelector = monitor.NamespaceSelector{
99-
MatchNames: []string{
100-
dpa.Namespace,
101-
},
102-
}
103-
104-
return nil
105-
}
106-
10714
func (r *DPAReconciler) ReconcileVeleroMetricsSVC(log logr.Logger) (bool, error) {
10815
dpa := oadpv1alpha1.DataProtectionApplication{}
10916
if err := r.Get(r.Context, r.NamespacedName, &dpa); err != nil {

controllers/monitor_test.go

Lines changed: 0 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -56,146 +56,6 @@ func getFakeClientFromObjectsForMonitor(objs ...client.Object) (client.WithWatch
5656
return fake.NewClientBuilder().WithScheme(schemeForFakeClient).WithObjects(objs...).Build(), nil
5757
}
5858

59-
func TestDPAReconciler_buildVeleroServiceMonitor(t *testing.T) {
60-
tests := []struct {
61-
name string
62-
serviceMonitor *monitor.ServiceMonitor
63-
dpa *oadpv1alpha1.DataProtectionApplication
64-
wantErr bool
65-
wantVeleroServiceMonitor *monitor.ServiceMonitor
66-
}{
67-
{
68-
name: "given appropriate dpa valid service monitor is built",
69-
serviceMonitor: &monitor.ServiceMonitor{
70-
ObjectMeta: metav1.ObjectMeta{
71-
Name: "openshift-adp-velero-metrics-sm",
72-
Namespace: "test-ns",
73-
},
74-
Spec: monitor.ServiceMonitorSpec{
75-
Selector: metav1.LabelSelector{
76-
MatchLabels: map[string]string{
77-
"app.kubernetes.io/name": common.Velero,
78-
"app.kubernetes.io/instance": "test-dpa",
79-
"app.kubernetes.io/managed-by": common.OADPOperator,
80-
"app.kubernetes.io/component": Server,
81-
oadpv1alpha1.OadpOperatorLabel: "True",
82-
},
83-
},
84-
},
85-
},
86-
dpa: &oadpv1alpha1.DataProtectionApplication{
87-
ObjectMeta: metav1.ObjectMeta{
88-
Name: "test-dpa",
89-
Namespace: "test-ns",
90-
},
91-
Spec: oadpv1alpha1.DataProtectionApplicationSpec{
92-
Configuration: &oadpv1alpha1.ApplicationConfig{
93-
Velero: &oadpv1alpha1.VeleroConfig{
94-
DefaultPlugins: []oadpv1alpha1.DefaultPlugin{
95-
oadpv1alpha1.DefaultPluginAWS,
96-
},
97-
},
98-
},
99-
BackupLocations: []oadpv1alpha1.BackupLocation{
100-
{
101-
CloudStorage: &oadpv1alpha1.CloudStorageLocation{
102-
CloudStorageRef: corev1.LocalObjectReference{
103-
Name: "bucket-123",
104-
},
105-
Config: map[string]string{},
106-
Credential: &corev1.SecretKeySelector{
107-
LocalObjectReference: corev1.LocalObjectReference{
108-
Name: "cloud-credentials",
109-
},
110-
Key: "creds",
111-
},
112-
Default: false,
113-
BackupSyncPeriod: &metav1.Duration{},
114-
},
115-
},
116-
},
117-
},
118-
},
119-
wantErr: false,
120-
wantVeleroServiceMonitor: &monitor.ServiceMonitor{
121-
ObjectMeta: metav1.ObjectMeta{
122-
Name: "openshift-adp-velero-metrics-sm",
123-
Namespace: "test-ns",
124-
Labels: map[string]string{
125-
"app.kubernetes.io/name": common.Velero,
126-
"app.kubernetes.io/instance": "test-dpa",
127-
"app.kubernetes.io/managed-by": common.OADPOperator,
128-
"app.kubernetes.io/component": Server,
129-
oadpv1alpha1.OadpOperatorLabel: "True",
130-
},
131-
},
132-
Spec: monitor.ServiceMonitorSpec{
133-
Selector: metav1.LabelSelector{
134-
MatchLabels: map[string]string{
135-
"app.kubernetes.io/name": common.Velero,
136-
"app.kubernetes.io/instance": "test-dpa",
137-
"app.kubernetes.io/managed-by": common.OADPOperator,
138-
"app.kubernetes.io/component": Server,
139-
oadpv1alpha1.OadpOperatorLabel: "True",
140-
},
141-
},
142-
Endpoints: []monitor.Endpoint{
143-
{
144-
Interval: "30s",
145-
Port: "monitoring",
146-
MetricRelabelConfigs: []*monitor.RelabelConfig{
147-
{
148-
Action: "keep",
149-
Regex: ("velero_backup_total|velero_restore_total"),
150-
SourceLabels: []string{
151-
"__name__",
152-
},
153-
},
154-
},
155-
},
156-
},
157-
NamespaceSelector: monitor.NamespaceSelector{
158-
MatchNames: []string{
159-
"test-ns",
160-
},
161-
},
162-
},
163-
},
164-
},
165-
}
166-
for _, tt := range tests {
167-
t.Run(tt.name, func(t *testing.T) {
168-
fakeClient, err := getFakeClientFromObjectsForMonitor(tt.serviceMonitor, tt.dpa)
169-
if err != nil {
170-
t.Errorf("error in creating fake client, likely programmer error")
171-
}
172-
r := &DPAReconciler{
173-
Client: fakeClient,
174-
Scheme: fakeClient.Scheme(),
175-
Log: logr.Discard(),
176-
Context: newContextForTest(tt.name),
177-
NamespacedName: types.NamespacedName{
178-
Namespace: tt.serviceMonitor.Namespace,
179-
Name: tt.serviceMonitor.Name,
180-
},
181-
EventRecorder: record.NewFakeRecorder(10),
182-
}
183-
184-
err = r.buildVeleroServiceMonitor(tt.serviceMonitor, tt.dpa)
185-
if (err != nil) != tt.wantErr {
186-
t.Errorf("buildVeleroServiceMonitor() error = %v, wantErr %v", err, tt.wantErr)
187-
return
188-
}
189-
if !reflect.DeepEqual(tt.wantVeleroServiceMonitor.Labels, tt.serviceMonitor.Labels) {
190-
t.Errorf("expected velero service monitor labels to be %#v, got %#v", tt.wantVeleroServiceMonitor.Labels, tt.serviceMonitor.Labels)
191-
}
192-
if !reflect.DeepEqual(tt.wantVeleroServiceMonitor.Spec, tt.serviceMonitor.Spec) {
193-
t.Errorf("expected velero service monitor spec to be %#v, got %#v", tt.wantVeleroServiceMonitor.Spec, tt.serviceMonitor.Spec)
194-
}
195-
})
196-
}
197-
}
198-
19959
func TestDPAReconciler_updateVeleroMetricsSVC(t *testing.T) {
20060
tests := []struct {
20161
name string
@@ -300,10 +160,6 @@ func TestDPAReconciler_updateVeleroMetricsSVC(t *testing.T) {
300160
}
301161

302162
err = r.updateVeleroMetricsSVC(tt.svc, tt.dpa)
303-
if (err != nil) != tt.wantErr {
304-
t.Errorf("buildVeleroServiceMonitor() error = %v, wantErr %v", err, tt.wantErr)
305-
return
306-
}
307163
if !reflect.DeepEqual(tt.wantVeleroMtricsSVC.Labels, tt.svc.Labels) {
308164
t.Errorf("expected velero metrics svc labels to be %#v, got %#v", tt.wantVeleroMtricsSVC.Labels, tt.svc.Labels)
309165
}

deploy/disconnected-prep.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,4 @@ for f in bundle/manifests/oadp-operator.clusterserviceversion.yaml
101101
if [[ "$f" =~ .*clusterserviceversion.* ]] && ! grep -q infrastructure-features ${f}; then
102102
sed -i '/^spec:/i\ \ \ \ operators.openshift.io/infrastructure-features: \x27[\"Disconnected\"]\x27' ${f}
103103
fi
104-
if [[ "$f" =~ .*clusterserviceversion.* ]] && ! grep -q cluster-monitoring ${f}; then
105-
sed -i '/^spec:/i\ \ \ \ operatorframework.io/cluster-monitoring: "true"' ${f}
106-
fi
107104
done

0 commit comments

Comments
 (0)