Skip to content

Commit

Permalink
Drop compatibility with older target allocator versions (#2850)
Browse files Browse the repository at this point in the history
We've made a breaking change to the target allocator configuration in
0.93.0. This change removes operator compatibility with target allocator
versions older than that.
  • Loading branch information
swiatekm authored Apr 13, 2024
1 parent 20b26bd commit 7c3b485
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 54 deletions.
19 changes: 19 additions & 0 deletions .chloggen/fix_drop-ta-config-backwards-compat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. collector, target allocator, auto-instrumentation, opamp, github action)
component: target allocator

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Drop compatibility with older target allocator versions

# One or more tracking issues related to the change
issues: [1907]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
We've made a breaking change to the target allocator configuration in 0.93.0. This change removes operator
compatibility with target allocator versions older than that. Users running more recent target allocator versions
are unaffected.
14 changes: 2 additions & 12 deletions controllers/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1372,11 +1372,6 @@ config:
- __meta_service_name
target_label: instance
filter_strategy: relabel-config
label_selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: test.test
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
prometheus_cr:
pod_monitor_selector: null
service_monitor_selector: null
Expand Down Expand Up @@ -1412,7 +1407,7 @@ prometheus_cr:
"app.kubernetes.io/version": "latest",
},
Annotations: map[string]string{
"opentelemetry-targetallocator-config/hash": "ba38217bad7e399f1210b90a464252159a8c4e17060c246799b8e4cb29a6f18f",
"opentelemetry-targetallocator-config/hash": "dd0ff440929239a362ebc85256b89e109d37bd2c77b400bd2039582cbda56be5",
},
},
Spec: corev1.PodSpec{
Expand Down Expand Up @@ -1771,11 +1766,6 @@ config:
- __meta_service_name
target_label: instance
filter_strategy: relabel-config
label_selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: test.test
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
prometheus_cr:
pod_monitor_selector: null
service_monitor_selector: null
Expand Down Expand Up @@ -1811,7 +1801,7 @@ prometheus_cr:
"app.kubernetes.io/version": "latest",
},
Annotations: map[string]string{
"opentelemetry-targetallocator-config/hash": "ba38217bad7e399f1210b90a464252159a8c4e17060c246799b8e4cb29a6f18f",
"opentelemetry-targetallocator-config/hash": "dd0ff440929239a362ebc85256b89e109d37bd2c77b400bd2039582cbda56be5",
},
},
Spec: corev1.PodSpec{
Expand Down
8 changes: 0 additions & 8 deletions controllers/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,17 +462,9 @@ func TestOpenTelemetryCollectorReconciler_Reconcile(t *testing.T) {
"app.kubernetes.io/part-of": "opentelemetry",
},
}
taConfig["label_selector"] = map[string]string{
"app.kubernetes.io/instance": "default.test",
"app.kubernetes.io/managed-by": "opentelemetry-operator",
"app.kubernetes.io/component": "opentelemetry-collector",
"app.kubernetes.io/part-of": "opentelemetry",
}
taConfig["config"] = promConfig["config"]
taConfig["allocation_strategy"] = "consistent-hashing"
taConfig["filter_strategy"] = "relabel-config"
taConfig["pod_monitor_selector"] = map[string]string{}
taConfig["service_monitor_selector"] = map[string]string{}
taConfig["prometheus_cr"] = map[string]any{
"scrape_interval": "30s",
"pod_monitor_selector": &metav1.LabelSelector{},
Expand Down
15 changes: 0 additions & 15 deletions internal/manifests/targetallocator/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) {
taConfig := make(map[interface{}]interface{})
prometheusCRConfig := make(map[interface{}]interface{})
taConfig["collector_selector"] = taSpec.CollectorSelector
// The below instruction is here for compatibility with the previous target allocator version
// TODO: Drop it after 3 more versions
taConfig["label_selector"] = taSpec.CollectorSelector.MatchLabels

// Add scrape configs if present
if instance.Spec.ScrapeConfigs != nil {
Expand All @@ -62,20 +59,8 @@ func ConfigMap(params manifests.Params) (*corev1.ConfigMap, error) {

prometheusCRConfig["service_monitor_selector"] = taSpec.PrometheusCR.ServiceMonitorSelector

// The below instruction is here for compatibility with the previous target allocator version
// TODO: Drop it after 3 more versions
if taSpec.PrometheusCR.ServiceMonitorSelector != nil {
taConfig["service_monitor_selector"] = &taSpec.PrometheusCR.ServiceMonitorSelector.MatchLabels
}

prometheusCRConfig["pod_monitor_selector"] = taSpec.PrometheusCR.PodMonitorSelector

// The below instruction is here for compatibility with the previous target allocator version
// TODO: Drop it after 3 more versions
if taSpec.PrometheusCR.PodMonitorSelector != nil {
taConfig["pod_monitor_selector"] = &taSpec.PrometheusCR.PodMonitorSelector.MatchLabels
}

if len(prometheusCRConfig) > 0 {
taConfig["prometheus_cr"] = prometheusCRConfig
}
Expand Down
19 changes: 0 additions & 19 deletions internal/manifests/targetallocator/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ config:
- 0.0.0.0:8888
- 0.0.0.0:9999
filter_strategy: relabel-config
label_selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: default.my-instance
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
prometheus_cr:
pod_monitor_selector: null
service_monitor_selector: null
Expand Down Expand Up @@ -106,13 +101,6 @@ config:
- 0.0.0.0:8888
- 0.0.0.0:9999
filter_strategy: relabel-config
label_selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: default.my-instance
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
pod_monitor_selector:
release: my-instance
prometheus_cr:
pod_monitor_selector:
matchlabels:
Expand All @@ -122,8 +110,6 @@ prometheus_cr:
matchlabels:
release: my-instance
matchexpressions: []
service_monitor_selector:
release: my-instance
`,
}
targetAllocator := targetAllocatorInstance()
Expand Down Expand Up @@ -172,11 +158,6 @@ config:
- 0.0.0.0:8888
- 0.0.0.0:9999
filter_strategy: relabel-config
label_selector:
app.kubernetes.io/component: opentelemetry-collector
app.kubernetes.io/instance: default.my-instance
app.kubernetes.io/managed-by: opentelemetry-operator
app.kubernetes.io/part-of: opentelemetry
prometheus_cr:
pod_monitor_selector: null
scrape_interval: 30s
Expand Down

0 comments on commit 7c3b485

Please sign in to comment.