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

ROX-27396: Collector configloader should not need to be modified when the protobuf is #1993

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

JoukoVirtanen
Copy link
Contributor

@JoukoVirtanen JoukoVirtanen commented Dec 13, 2024

Description

Currently every time that CollectorConfig protobuf definition is changed, we have to change the code for the ConfigLoader. The changes here make it so that is not necessary.

There are also changes here that make it so that collector logs are written to the correct location. Currently for tests that have sub-tests, collector logs are only written to the directory for the first sub-test. This PR fixes that.

Checklist

  • Investigated and inspected CI test results
  • Updated documentation accordingly

Automated testing

  • Added unit tests
  • Added integration tests
  • Added regression tests

If any of these don't apply, please comment below.

Testing Performed

Unit and integration tests are sufficient.

@JoukoVirtanen JoukoVirtanen requested a review from a team as a code owner December 13, 2024 00:58
@JoukoVirtanen JoukoVirtanen marked this pull request as draft December 13, 2024 00:58
sensor::CollectorConfig runtimeConfig;
google::protobuf::util::JsonParseOptions parseOptions;
parseOptions.ignore_unknown_fields = true;
auto status = google::protobuf::util::JsonStringToMessage(jsonStr, &runtimeConfig, parseOptions);
Copy link
Contributor Author

@JoukoVirtanen JoukoVirtanen Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems silly to first convert to json, then json string, and then to the protobuf class, instead of converting more directly, and it likely is silly. The reason I did this is that this way I don't have to worry as much about the types. E.g. when converting from yaml, in this case, the code assumes that all the values are strings. This is later fixed by JsonStringToMessage. However, if we tried to convert to the protobuf class directly to the json class used by protobuf, we would first have to figure out the type before doing the conversion.

@@ -42,34 +42,16 @@ TEST(CollectorConfigTest, TestYamlConfigToConfigMultiple) {
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would have the same behavior as before and no changes to the unit tests would have to be made. However, there the old code had checks that the networking field was present and not blank and with the new more general approach this check is not done. Also the old allowed for the yaml to have invalid values, but JsonStringToMessage does not allow that.

@JoukoVirtanen JoukoVirtanen marked this pull request as ready for review December 16, 2024 19:22
@JoukoVirtanen JoukoVirtanen force-pushed the jv-ROX-27396-collector-configloader-should-not-need-to-be-modified-when-the-protobuf-is branch from 3a0162e to f1c0f05 Compare January 2, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant