Skip to content

Mutating webhook overwrites service.telemetry when using declarative resource.attributes schema #5207

Description

@elliehmy

Component(s)

collector

What happened?

Description

OpenTelemetry Collector v0.151.0 added support for declarative service.telemetry.resource.attributes configuration.

However, the OpenTelemetry Operator mutating webhook still parses service.telemetry.resource as a legacy inline map (map[string]*string). Because of this, an OpenTelemetryCollector CR using the new declarative resource schema can be mutated unexpectedly.

  • When GetTelemetry fails to unmarshal the new schema, ServiceApplyDefaults treats it as an empty config and overwrites s.Telemetry.Object, dropping the user input before injecting the default Prometheus reader.

The operator webhook should support both service.telemetry.resource formats:

Legacy inline map:

  resource:
    service.name: my-collector

Declarative resource schema:

  resource:
    attributes:
      - name: service.name
        value: my-collector

Steps to Reproduce

Given this Collector-valid configuration:

  service:
    telemetry:
      resource:
        attributes:
          - name: deployment.environment.name
            value: production
      metrics:
        level: detailed
        readers:
          - periodic:
              interval: 60000
              exporter:
                otlp:
                  protocol: grpc
                  endpoint: otel-collector:4317
                  insecure: true

Expected Result

The webhook leaves service.telemetry untouched (the user explicitly configured metrics.readers), and the rendered ConfigMap preserves both resource.attributes and the OTLP periodic reader.

Actual Result

The mutating webhook injects the default Prometheus metrics reader:

  service:
    telemetry:
      metrics:
        readers:
          - pull:
              exporter:
                prometheus:
                  host: 0.0.0.0
                  port: 8888
                  without_scope_info: false
                  without_type_suffix: false
                  without_units: false

User-provided resource, metrics.level, and configured readers are gone.

As a workaround, we can use the legacy inline map format. But, Collector v0.153.0 then emits a warning:

Using legacy service.telemetry.resource inline map format; prefer service.telemetry.resource.attributes
(array of maps with name and value keys)

Kubernetes Version

1.26.4

Operator version

0.152.0

Collector version

0.153.0

Environment information

Environment

OS: (e.g., "Ubuntu 20.04")
Compiler(if manually compiled): (e.g., "go 14.2")

Log output

Additional context

No response

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:collectorIssues for deploying collectorbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions