Skip to content

Commit 922e7a1

Browse files
authored
fix(target-allocator): check for Prometheus CRDs before watching Service/Pod Monitors (#3728)
* fix(target-allocator): check for Prometheus CRDs before watching Service/Pod Monitors * Add changelog file
1 parent d2c4bb2 commit 922e7a1

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

.chloggen/fix-3726.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
2+
change_type: 'bug_fix'
3+
4+
# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
5+
component: 'target allocator'
6+
7+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
8+
note: check for Prometheus CRDs before watching Service/Pod Monitors
9+
10+
# One or more tracking issues related to the change
11+
issues: [3726]
12+
13+
# (Optional) One or more lines of additional information to render under the primary note.
14+
# These lines will be padded with 2 spaces and then inserted directly into the document.
15+
# Use pipe (|) for multiline entries.
16+
subtext:

controllers/targetallocator_controller.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828

2929
"github.com/open-telemetry/opentelemetry-operator/apis/v1alpha1"
3030
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
31+
"github.com/open-telemetry/opentelemetry-operator/internal/autodetect/prometheus"
3132
"github.com/open-telemetry/opentelemetry-operator/internal/config"
3233
"github.com/open-telemetry/opentelemetry-operator/internal/manifests/targetallocator"
3334
taStatus "github.com/open-telemetry/opentelemetry-operator/internal/status/targetallocator"
@@ -190,7 +191,7 @@ func (r *TargetAllocatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
190191
Owns(&appsv1.Deployment{}).
191192
Owns(&policyV1.PodDisruptionBudget{})
192193

193-
if featuregate.PrometheusOperatorIsAvailable.IsEnabled() {
194+
if featuregate.PrometheusOperatorIsAvailable.IsEnabled() && r.config.PrometheusCRAvailability() == prometheus.Available {
194195
ctrlBuilder.Owns(&monitoringv1.ServiceMonitor{})
195196
ctrlBuilder.Owns(&monitoringv1.PodMonitor{})
196197
}

0 commit comments

Comments
 (0)