-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Enhance config validation by Instantiating service
during dryrun.
#12488
base: main
Are you sure you want to change the base?
Enhance config validation by Instantiating service
during dryrun.
#12488
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #12488 +/- ##
==========================================
+ Coverage 92.00% 92.03% +0.03%
==========================================
Files 469 469
Lines 25355 25358 +3
==========================================
+ Hits 23327 23339 +12
+ Misses 1619 1613 -6
+ Partials 409 406 -3 ☔ View full report in Codecov by Sentry. |
89f448f
to
754e9a7
Compare
Some tests are failing, which are not related to this PR. Any guidance would be helpful. |
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.
What are the errors that were not reported before that are reported after this change? Can we instead statically validate those?
Feel free to ignore the errors, they are not related to this PR |
@mx-psi Thanks for the quick response!
This approach should catch all errors in the pipeline configuration. I am not aware of it all, but here are a couple of examples. Especially for 1. Improper Connector Use invalid_config.yamlreceivers:
otlp:
protocols:
grpc:
exporters:
debug:
connectors:
forward:
service:
pipelines:
logs/in:
receivers: [otlp]
processors: []
exporters: [forward]
logs/in2:
receivers: [ otlp ]
processors: [ ]
exporters: [ forward ]
logs/out:
receivers: [otlp]
processors: []
exporters: [debug]
traces:
receivers: [ otlp ]
processors: [ ]
exporters: [ forward ]
metrics:
receivers: [ forward ]
processors: [ ]
exporters: [ debug ] Before: No error detected Proposed Change: Error: failed to build pipelines: connector "forward" used as exporter in [logs/in2 logs/in] pipeline but not used in any supported receiver pipeline
2025/02/25 16:58:09 collector server run finished with error: failed to build pipelines: connector "forward" used as exporter in [logs/in2 logs/in] pipeline but not used in any supported receiver pipeline
2. Unused Connector invalid_config.yamlreceivers:
otlp:
protocols:
grpc:
http:
exporters:
debug:
connectors:
forward:
service:
pipelines:
logs/out:
receivers: [forward]
processors: []
exporters: [debug] Before: No error detected Proposed Change: Error: failed to build pipelines: connector "forward" used as receiver in [logs/out] pipeline but not used in any supported exporter pipeline
2025/02/26 10:40:53 collector server run finished with error: failed to build pipelines: connector "forward" used as receiver in [logs/out] pipeline but not used in any supported exporter pipeline
2. Cycle in the Pipeline invalid_config.yamlreceivers:
otlp:
protocols:
grpc:
exporters:
debug:
connectors:
forward:
service:
pipelines:
traces/in:
receivers: [forward]
processors: [ ]
exporters: [forward]
traces/out:
receivers: [forward]
processors: [ ]
exporters: [forward] Before: No error detected Proposed Change: Error: failed to build pipelines: cycle detected: connector "forward" (traces to traces) -> connector "forward" (traces to traces)
2025/02/26 11:12:53 collector server run finished with error: failed to build pipelines: cycle detected: connector "forward" (traces to traces) -> connector "forward" (traces to traces)
|
754e9a7
to
b863577
Compare
16f3e68
to
bce7fac
Compare
_, err = col.createService(ctx, cfg, factories) | ||
return err |
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.
why this? Why do we need to start things to make sure we are ok?
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.
I think it does not start a service. As mentioned in this #8721 (comment) we can surface configuration errors by instantiating the service during a dry run. This will initialize the graph, and detect cycles and other errors which might prevent the service to start.
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.
I would prefer the DryRun to not have to start the collector, what do we miss that we need to do this?
These are the error that current 1. Improper Connector Use invalid_config.yamlreceivers:
otlp:
protocols:
grpc:
exporters:
debug:
connectors:
forward:
service:
pipelines:
logs/in:
receivers: [otlp]
processors: []
exporters: [forward]
logs/in2:
receivers: [ otlp ]
processors: [ ]
exporters: [ forward ]
logs/out:
receivers: [otlp]
processors: []
exporters: [debug]
traces:
receivers: [ otlp ]
processors: [ ]
exporters: [ forward ]
metrics:
receivers: [ forward ]
processors: [ ]
exporters: [ debug ] Before: No error detected Proposed Change: Error: failed to build pipelines: connector "forward" used as exporter in [logs/in2 logs/in] pipeline but not used in any supported receiver pipeline
2025/02/25 16:58:09 collector server run finished with error: failed to build pipelines: connector "forward" used as exporter in [logs/in2 logs/in] pipeline but not used in any supported receiver pipeline
2. Unused Connector invalid_config.yamlreceivers:
otlp:
protocols:
grpc:
http:
exporters:
debug:
connectors:
forward:
service:
pipelines:
logs/out:
receivers: [forward]
processors: []
exporters: [debug] Before: No error detected Proposed Change: Error: failed to build pipelines: connector "forward" used as receiver in [logs/out] pipeline but not used in any supported exporter pipeline
2025/02/26 10:40:53 collector server run finished with error: failed to build pipelines: connector "forward" used as receiver in [logs/out] pipeline but not used in any supported exporter pipeline
2. Cycle in the Pipeline invalid_config.yamlreceivers:
otlp:
protocols:
grpc:
exporters:
debug:
connectors:
forward:
service:
pipelines:
traces/in:
receivers: [forward]
processors: [ ]
exporters: [forward]
traces/out:
receivers: [forward]
processors: [ ]
exporters: [forward] Before: No error detected Proposed Change: Error: failed to build pipelines: cycle detected: connector "forward" (traces to traces) -> connector "forward" (traces to traces)
2025/02/26 11:12:53 collector server run finished with error: failed to build pipelines: cycle detected: connector "forward" (traces to traces) -> connector "forward" (traces to traces)
|
Description
As mentioned in #8721 (comment), we can surface configuration errors by instantiating the service during a dry run.
Expanding on this idea, this PR enhances configuration validation. The validate command will now capture all validation errors that would prevent the collector from starting.
Link to the tracking issue
Fixes #8721
Testing
Added unit tests. Also, a few scenarios and example output are given below. I will add more unit tests if necessary.
1. Improper Connector Use
invalid_config.yaml
Before: No error detected
Proposed Change:
2. Unused Connector
invalid_config.yaml
Before: No error detected
Proposed Change:
2. Cycle in the Pipeline
invalid_config.yaml
Before: No error detected
Proposed Change:
Note
I removed the following log as it seemed redundant to me and it is also surfaced during validation. Let me know if we absolutely need to keep it
opentelemetry-collector/service/service.go
Line 193 in 5812712