-
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
Static validation of improper connector usage in config files during dry-run #12681
base: main
Are you sure you want to change the base?
Static validation of improper connector usage in config files during dry-run #12681
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #12681 +/- ##
==========================================
- Coverage 91.55% 91.55% -0.01%
==========================================
Files 481 481
Lines 26391 26420 +29
==========================================
+ Hits 24162 24188 +26
- Misses 1766 1768 +2
- Partials 463 464 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…dry runs Signed-off-by: sudipto baral <[email protected]>
Signed-off-by: sudipto baral <[email protected]>
Signed-off-by: sudipto baral <[email protected]>
Signed-off-by: sudipto baral <[email protected]>
18bab32
to
bf9fe79
Compare
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.
minor comments, otherwise LGTM
Factories: nopFactories, | ||
ConfigProviderSettings: newDefaultConfigProviderSettings(t, []string{filepath.Join("testdata", "otelcol-invalid-connector-use.yaml")}), | ||
}, | ||
expectedErr: `connector "nop/connector1" used as exporter in [logs/in2] pipeline but not used in any supported receiver pipeline`, |
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.
could you add another case on connector being used in receivers but not in exporters?
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.
added new tests
service/service_test.go
Outdated
|
||
err := ValidateConnectors(connectorCfg, pipelinesCfg, connectorsFactories) | ||
require.Error(t, err) | ||
assert.Equal(t, "connector \"nop/connector1\" used as exporter in [logs/in2] pipeline but not used in any supported receiver pipeline", err.Error()) |
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.
same here
Signed-off-by: sudipto baral <[email protected]>
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.
Can't we just instantiate the graph as usual and check for an error?
In my opinion adding special code paths for validation unnecessarily complicates an already complex package. Instantiating the graph should be a low cost and repeatable operation which returns verbose errors if the graph is invalid. |
Yes, I agree, If we instantiate the graph we will also be able to surface cycle errors which is not possible to capture in this approach. |
Description
As described in #8721, the current
validate
command cannot capture improper connector usage errors during a dry run.One possible solution (as mentioned in this comment) is to surface configuration errors by instantiating the service during a dry run. However, reviewers indicated that statically verifying the errors is preferable to instantiating the service (see the PR
#12488 comments).
Currently, the validation logic for connectors is embedded in the
service/internal/graph
package. This PR extracts the relevant validation logic and uses it duringdry-run
to statically validate connector configurations.Link to tracking issue
Fixes #8721