-
Notifications
You must be signed in to change notification settings - Fork 13
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
combine not honoring comments location #66
Comments
Yes, this is a known limitation. The solution requires re-writing the parser so that comments are no longer just second-class citizens. I mean, they will always be "lesser" because they don't have any functional impact, but they should be preserved, where possible. Where do comments belong?Sometimes it's impossible to always determine what entity a comment should be associated to. Take for example:
How can the parser know if a comment goes with the stanza before or after it? How do you know if a comment should be pinned to an attribute? Should the comment be before or after the attribute? I eventually want the option to (where possible) preserve stanza ordering and/or key ordering on a file-by-file basis. Specifically props.conf and transforms.conf are often managed by hand, where comments greatly enhance reliability. But for now pretty much every time ksconf writes to a Current behaviorRight now the behavior is:
Preserving order with complex commandsCertain operations, like merge, combine, or promote are very likely never going to support preservation of comments. And the reason is that it gets too complex too fast, and it hasn't been worth the effort to try to implement this. How should comments be "meged"? Suppose we could solve the above problem of figuring out where a comment belongs. The next question is how would you merge them across stanzas? Should identical comments be suppressed and just outputted once? What if an identical lines are in a different order between two files? What if the same comment is present in 3 out of 4 files, and the 4th file is the highest precedence. Should that comment be removed? The primary purpose of these higher-order tools is to provide output that's usable by Splunk; not humans. If ksconf gets widely adopted by app developers and they really need this feature; then I'm sure we could come up with some meta-language or markup feature to "inject" comments into the output files. But I think that would end up being way to tedious for anyone simply trying to manage their own Splunk environment (so I'd consider that a different feature entirely.) As much as it annoys me to have my comments screwed up; I've learned to live with it (at least for now). I haven't been able to justify prioritizing the effort required to properly fix this over all the other things that make a functional impact. Also keep in mind, that any conf file that Splunk edits is subject to the same potential chaotic updates ;-( TL;DR
|
Reviewing tickets and just realized that I didn't point out the other obvious solution. Just place the string |
The problem
ksconf combine moves comment lines around in the target files. This makes it challenging to understand the comments intentions. It also reorders (sort?) the stanzas, which can sound like a good idea... until that alters the logical flow of the code within a .conf file. Yes, I realize it does not change how Splunk parses/combines the configs, but often developers place things in a certain order on purpose.
Environment
Details
Here is an Splunk_TA_Windows original /default/wmi.conf
and wmi.conf after ksconf combine (I have no local changes so this should just be a file copy).
Note how the comments related to [WMI:LocalApplication] were moved under [settings] which would lead an admin astray.
The text was updated successfully, but these errors were encountered: