-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Provide better info in the default netdata.conf, and unfiy it with the header used for generating config at runtime. #17733
base: master
Are you sure you want to change the base?
Conversation
Include a link to the documentation, and also better describe the duumpconfig and /netdata.conf stuff.
This modifies how we are handling generation of the config file exposed via the /netdata.conf endpoint and the dumpconfig command so that the file header is provided by system/netdata.conf. These changes achieve this by adding a CMake script to generate a header file with a single define containing the text of system/netdata.conf. CMake was chosen for this instead of something like Python because it’s implicitly portable to all of our target systems, does not add a new build-time dependency, and surprisingly enough it’s both simpler and faster for this specific task. Overall, this reduces duplication in the code, and ensures that users get the same info in the comments at the top of netdata.conf regardless of the source of the file.
What places? |
They were different. They are functionally not any more, even though the content is currently different (because Drawing from one place for both means we only ever have to update that information that should stay in-sync in one place. |
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. You can use python to do this and avoid locking us into cmake.
Or even better, install a hidden/default netdata.conf -> open/read its contents and print it when dumping the runtime netdata.conf. |
@vkalintiris The intent behind using CMake here was that:
I actually did consider loading the file at runtime, but I had expected the additional complexity that would be required to correctly handle that would be a major point of contention. If that’s really the route we want to take I can rewrite it though. |
It is. We don't want to rely on the build to system to generate source code at configuration time. |
Summary
The first half of this PR is simply clean up and improvements in the default config file (
system/netdata.conf
) that gets installed at build time. Most of that should be completely non-controversial, and should better help users who are looking to configure the agent.The second half of the PR involves adjusting
src/libnetdata/config/appconfig.c
to usesystem/netdata.conf
as the header when it generates the config that gets output bynetdatacli dumpconfig
or the/netdata.conf
API endpoint. This ensures that the information in both places stays in sync properly, and also makes the function responsible for this generation a bit easier to read.The majority of the changes involved in the second half of the PR revolve around a new CMake script (
packaging/cmake/txt2header.cmake
) that converts a text file to a C header file that defines a macro which expands to a string consisting of the contents of that text file. This was done in CMake mostly to ensure portability, but it’s also significantly simpler and faster to do this type of simple text transformation in CMake.Test Plan
Primary testing involves verifying that CI passes on this PR.
Secondary testing involves building the agent, running it, and then inspecting the output of
netdatacli dumpconfig
or the/netdata.conf
web API endpoint to confirm that the headers there match the contents ofsystem/netdata.conf
.