Skip to content
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

Variables in comments in config files that are included are interpolated #10787

Closed
antonio opened this issue Aug 1, 2024 · 1 comment · Fixed by #10795
Closed

Variables in comments in config files that are included are interpolated #10787

antonio opened this issue Aug 1, 2024 · 1 comment · Fixed by #10795
Assignees
Labels
area:confmap bug Something isn't working release:blocker The issue must be resolved before cutting the next release

Comments

@antonio
Copy link

antonio commented Aug 1, 2024

Describe the bug
String interpolation is being applied to comments in config files that are included from another config file, which can cause errors and prevent the collector from starting.

Steps to reproduce
Start the collector with the following config:

config.yaml

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
      http:
        endpoint: 0.0.0.0:4318
processors:
  batch:

exporters:
  ${file:logging.yaml}

service:
  telemetry:
    metrics:
      level: detailed
  pipelines:
    traces:
      receivers: [otlp]
      processors: [batch]
      exporters: [logging]

logging.yaml

# ${hello.world}
logging:
  verbosity: detailed

What did you expect to see?
The collector should ignore the comment and carry on.

What did you see instead?
The collector tried to replace the variable in the comment with an environment variable that does not exist and exited with an error.

❯ ./otelcol validate --config=config.yaml
Error: failed to get config: cannot resolve the configuration: environment variable "hello.world" has invalid name: must match regex ^[a-zA-Z_][a-zA-Z0-9_]*$
2024/08/01 20:06:33 collector server run finished with error: failed to get config: cannot resolve the configuration: environment variable "hello.world" has invalid name: must match regex ^[a-zA-Z_][a-zA-Z0-9_]*$

What version did you use?
v0.106.1

What config did you use?
See above

Environment
I've manually replicated this on MacOS, go 1.22.5, but I've also seen it fail in CI (Ubuntu, different go versions)

Additional context
Versions prior to v0.106.0 did not have this issue.

~/Code/opentelemetry-collector-contrib
❯ ./otelcol validate --config=config.yaml

~/Code/opentelemetry-collector-contrib
❯ echo $?
0

~/Code/opentelemetry-collector-contrib
❯ ./otelcol --version
otelcol version 0.105.0
@antonio antonio added the bug Something isn't working label Aug 1, 2024
@mx-psi mx-psi self-assigned this Aug 2, 2024
@mx-psi mx-psi added area:confmap release:blocker The issue must be resolved before cutting the next release labels Aug 2, 2024
@mx-psi
Copy link
Member

mx-psi commented Aug 2, 2024

I believe this was caused by #10618 since we now try to parse the raw string as well in case we want to use the value as a string. The fix is to delay erroring out until we know that we have to use it as a string. I will mark this as release:blocker and fix it for v0.107.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:confmap bug Something isn't working release:blocker The issue must be resolved before cutting the next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants