-
Notifications
You must be signed in to change notification settings - Fork 626
Fix(target-allocator): accept prometheus receiver with only target_allocator block #5085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sashetov
wants to merge
1
commit into
open-telemetry:main
Choose a base branch
from
sashetov:fix/target-allocator-only-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: bug_fix | ||
|
|
||
| # 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: Accept a prometheus receiver that only declares `target_allocator:` without a `config:` block. | ||
|
|
||
| # One or more tracking issues related to the change | ||
| issues: [2998] | ||
|
|
||
| # (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: | | ||
| When the prometheus receiver is configured with only a `target_allocator:` block and no `config:`, | ||
| reconciliation previously failed with `no prometheusConfig available as part of the configuration`. | ||
| The target allocator supplies scrape configuration externally in this mode (e.g. via discovered | ||
| PrometheusCR objects), so the operator now skips the scrape_configs cleanup when no `config:` | ||
| block is present. The webhook validator likewise permits this shape. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
tests/e2e-targetallocator/targetallocator-no-promconfig/00-assert.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| apiVersion: apps/v1 | ||
| kind: StatefulSet | ||
| metadata: | ||
| name: no-promconfig-collector | ||
| status: | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| --- | ||
| apiVersion: apps/v1 | ||
| kind: Deployment | ||
| metadata: | ||
| name: no-promconfig-targetallocator | ||
| status: | ||
| observedGeneration: 1 | ||
| readyReplicas: 1 | ||
| replicas: 1 | ||
| --- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: no-promconfig-targetallocator | ||
| --- | ||
| # The rendered collector config must contain the operator-injected | ||
| # target_allocator block but no `config:` key under prometheus (the user | ||
| # didn't supply one and the operator should not synthesise one). | ||
| apiVersion: v1 | ||
| data: | ||
| collector.yaml: | | ||
| exporters: | ||
| prometheus: | ||
| endpoint: 0.0.0.0:9090 | ||
| receivers: | ||
| prometheus: | ||
| target_allocator: | ||
| collector_id: ${POD_NAME} | ||
| endpoint: http://no-promconfig-targetallocator:80 | ||
| interval: 30s | ||
| service: | ||
| pipelines: | ||
| metrics: | ||
| exporters: | ||
| - prometheus | ||
| receivers: | ||
| - prometheus | ||
| telemetry: | ||
| metrics: | ||
| readers: | ||
| - pull: | ||
| exporter: | ||
| prometheus: | ||
| host: 0.0.0.0 | ||
| port: 8888 | ||
| without_scope_info: false | ||
| without_type_suffix: false | ||
| without_units: false | ||
| kind: ConfigMap | ||
| metadata: | ||
| labels: | ||
| app.kubernetes.io/component: opentelemetry-collector | ||
| app.kubernetes.io/managed-by: opentelemetry-operator | ||
| app.kubernetes.io/name: no-promconfig-collector |
81 changes: 81 additions & 0 deletions
81
tests/e2e-targetallocator/targetallocator-no-promconfig/00-install.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| apiVersion: v1 | ||
| automountServiceAccountToken: true | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: collector | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
| metadata: | ||
| name: collector-no-promconfig | ||
| rules: | ||
| - apiGroups: | ||
| - "" | ||
| resources: | ||
| - pods | ||
| - nodes | ||
| - nodes/metrics | ||
| - services | ||
| - endpoints | ||
| - namespaces | ||
| verbs: | ||
| - get | ||
| - watch | ||
| - list | ||
| - apiGroups: | ||
| - networking.k8s.io | ||
| resources: | ||
| - ingresses | ||
| verbs: | ||
| - get | ||
| - watch | ||
| - list | ||
| - nonResourceURLs: | ||
| - /metrics | ||
| - /metrics/cadvisor | ||
| verbs: | ||
| - get | ||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
| metadata: | ||
| name: (join('-', ['collector', $namespace])) | ||
| roleRef: | ||
| apiGroup: rbac.authorization.k8s.io | ||
| kind: ClusterRole | ||
| name: collector-no-promconfig | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: collector | ||
| namespace: ($namespace) | ||
| --- | ||
| # Regression manifest for #2998: prometheus receiver has no `config:` block. | ||
| # Scrape configuration is delegated entirely to the target allocator, which | ||
| # loads it from PrometheusCR objects discovered in-cluster. The webhook used | ||
| # to reject this shape; reconciliation used to fail on it. | ||
| apiVersion: opentelemetry.io/v1beta1 | ||
| kind: OpenTelemetryCollector | ||
| metadata: | ||
| name: no-promconfig | ||
| spec: | ||
| config: | ||
| receivers: | ||
| prometheus: {} | ||
| exporters: | ||
| prometheus: | ||
| endpoint: 0.0.0.0:9090 | ||
|
Comment on lines
+65
to
+66
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I don't think there's a reason to use a more complex exporter here. |
||
| service: | ||
| pipelines: | ||
| metrics: | ||
| receivers: [prometheus] | ||
| exporters: [prometheus] | ||
| mode: statefulset | ||
| serviceAccount: collector | ||
| targetAllocator: | ||
| enabled: true | ||
| prometheusCR: | ||
| enabled: true | ||
| scrapeInterval: 1s | ||
| serviceMonitorSelector: {} | ||
| podMonitorSelector: {} | ||
| serviceAccount: ta | ||
27 changes: 27 additions & 0 deletions
27
tests/e2e-targetallocator/targetallocator-no-promconfig/chainsaw-test.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json | ||
| apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
| kind: Test | ||
| metadata: | ||
| creationTimestamp: null | ||
| name: targetallocator-no-promconfig | ||
| spec: | ||
| steps: | ||
| - name: Setup Target Allocator RBAC | ||
| use: | ||
| template: ../../step-templates/target-allocator-rbac-comprehensive.yaml | ||
| with: | ||
| bindings: | ||
| - name: clusterRoleName | ||
| value: targetallocator-no-promconfig | ||
| - name: clusterRoleBindingName | ||
| value: (join('-', ['ta', $namespace])) | ||
| - name: step-00 | ||
| try: | ||
| - apply: | ||
| template: true | ||
| file: 00-install.yaml | ||
| - assert: | ||
| file: 00-assert.yaml | ||
| catch: | ||
| - podLogs: | ||
| selector: app.kubernetes.io/managed-by=opentelemetry-operator |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's safer to make the name the same as the ClusterRoleBinding, reduce the chance of collisions with other tests. Those have historically been a source of strange bugs.