Quash my.cnf.epp template's extra-newline issues#1718
Open
greatflyingsteve wants to merge 2 commits into
Open
Conversation
When templates were changed from ERB to EPP, a bunch of comments naming that conversion as an outstanding TODO were not removed from manifest code. To avoid confusion, remove the TODO comments; that work is done.
The my.cnf.epp template was not converted from ERB to EPP very well, with seemingly little attention paid to the template bracketry's newline suppression. It inserts tons of random newlines into the body of the config file in weird random places, causing unnecessary diffs when upgrading from prior module versions and resulting in a weirdly sparse config layout that's more difficult to read. The template logic was also obtuse and not especially easy to read or reason about, nor was it particularly efficient, producing a lot of values that would have been immediately discarded, prefering obtuse approaches, and failing to embrace the side-effects through which template rendering inherently works. These should be somewhat better now. Ruby and Puppet are related languages, but not identical; what makes sense in one will not always make sense in the other.
Author
|
In real testing on the same host on which I was seeing the diffs shown above, all the extra newlines are removed. At the end of all sections, before |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The my.cnf.epp template was not converted from ERB to EPP very well, with seemingly little attention paid to the template bracketry's newline suppression. It inserts tons of random newlines into the body of the config file in weird random places, causing unnecessary diffs when upgrading from prior module versions and resulting in a weirdly sparse config layout that's more difficult to read.
The template logic was also obtuse and not especially easy to read or reason about, nor was it particularly efficient, producing a lot of values that would have been immediately discarded, prefering obtuse approaches, and failing to embrace the side-effects through which template rendering inherently works. These should be somewhat better now. Ruby and Puppet are related languages, but not identical; what makes sense in one will not always make sense in the other.
Also remove a few leftover TODO comments that all cite the aforementioned conversion as a thing that still needs to be done, despite being done already.
Additional Context
The issue is that while the original ERB template did the sensible thing and added a newlines after every line it added to the output, the translated EPP template for some reason tries to add newlines at loop exit instead of at line output. Because not all iterations through a loop add template output, and exiting multiple loops at once (end of a section, end of all sections, etc.), will add newlines for each exited loop, this yields predictably abysmal results.
Upgrading from a pre-v16.0.0 version of this module (prior to the template's conversion to EPP) to v16.3.0 of this module, with no other changes of any kind, with an
override_optionshash that included the following:...resulted in diffs that looked like this:
And to walk through this a little bit, this was:
'ssl' => falseprints nothing, still adds a newline when we exit that iteration'ssl-disable' => false(from default_options in params.pp) prints nothing, still adds a newline when we exit that iterationmysqldsection): post-v16.x, ending any section adds one more newlinemysqld-5.0section): post-v16.x, ending any section adds a second newlinemysqld-5.1section): post-v16.x, ending any section adds a second newline'query_cache_limit' => undefprints nothing, still adds a newline when we exit that iteration'query_cache_size' => undefprints nothing, still adds a newline when we exit that iterationmysqld-5.5section): post-v16.x, ending any section adds a second newline'query_cache_limit' => undefprints nothing, still adds a newline when we exit that iteration'query_cache_size' => undefprints nothing, still adds a newline when we exit that iterationmysqld-5.6section): post-v16.x, ending any section adds a second newlineThis approach to newlines is fundamentally broken. Newlines should be added whenever we've just printed a line, and should not be added unless we've added a line or done something significant like end a section (though in that case, ideally, we just get one extra, as previously). This change returns to exactly that approach, exactly like the ERB template used to do; and in addition, adds unit tests to catch this if anyone screws it up again.
Checklist
puppet apply)