-
Notifications
You must be signed in to change notification settings - Fork 77
Cleanup configuration representation. #143
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
Conversation
84471f1 to
0472e6f
Compare
Missing functionality: - entity id is not known at YAML unmarshal time, so replaced with question marks - platform is not known at YAML unmarshal time, so all registered types are considered valid
d23609a to
12bf723
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.
Some suggested comments to add. More to come.
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.
Some more config.go comments.
| if err != nil { | ||
| t.Fatalf("ReadFile(%q) got: %v", userSpecifiedConfPath, err) | ||
| } | ||
| t.Logf("merged config:\n%s", data) |
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.
[Optional] Can we log the built-in config and user specified config as well? This helps with diagnosing old agent issues when the config might have been edited already, and customer might want to trace back to the config content at the time of incident.
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.
This is a unit test... there's no old customer config in a unit test :P It's not easy to add logging of the pre-merge configs in the unit test for now. Hopefully will be possible when I do more refactoring.
As for logging these in the real daemon, yeah, we should do that but that will come later.
confgenerator/config.go
Outdated
| } | ||
| } | ||
| sort.Strings(supportedTypes) | ||
| return fmt.Errorf(`%s %s %q with type %q is not supported. Supported %s %s types: [%s].`, |
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.
We probably need to remove the "???" part for now if receiver / processor / exporter ID is not available at this point.
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.
These error messages are all going to get cleaned up later in a separate PR. But I removed the ??? for now so it's not as confusing.
| @@ -1,2 +1 @@ | |||
| the agent config file is not valid YAML. detailed error: yaml: unmarshal errors: | |||
| line 6: cannot unmarshal !!str `abc` into uint16 No newline at end of file | |||
| the agent config file is not valid. detailed error: cannot unmarshal string into Go struct field UnifiedConfig.Logging of type uint16 No newline at end of file | |||
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.
This one looks a bit different from others as it does not print the config snippet. Is that expected?
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.
No, I don't know why it's missing the line number and snippet. Nor why it says unmarshal string into [...] uint16. Worth investigating later.
| @@ -1 +1,9 @@ | |||
| logging processor id "lib:processor_1" is not allowed because prefix 'lib:' is reserved for pre-defined processors. | |||
| the agent config file is not valid. detailed error: [9:20] Key: 'Logging.processors[lib:processor_1]' Error:Field validation for 'processors[lib:processor_1]' failed on the 'startsnotwith' tag | |||
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.
The new message does not mention what prefix is forbidden. Not too bad though as we could add a note to the troubleshooting guide.
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.
Improving all of these error messages is a TODO. We can easily add that back and more, but I'm prioritizing getting a stable interface ready for BM first.
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.
Finished reviewing the remaining files.
confgenerator/testdata/invalid/linux/logging-pipeline_reserved_id_prefix/golden_error
Show resolved
Hide resolved
| @@ -1 +1,9 @@ | |||
| parameter "transport_protocol" in "files" type logging receiver "receiver_1" is not supported. Supported parameters: [include_paths, exclude_paths]. | |||
| the agent config file is not valid. detailed error: [8:7] unknown field "transport_protocol" | |||
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.
We can remove some of these validation tests as redundant. Follow-up work.
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.
Which one(s) are redundant?
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.
A bunch of these tests have the form "invalid field X for type Y", because we had to explicitly check each field in the old code.
Now with the validate tags, I think we can just have a single such test.
Extracted from #141 and rebased on top of the merged #142. Can split up further if needed.