-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
contents_newline in file.managed is effectively ignored #54177
Comments
Confirmed. We ran into this exact same bug when upgrading to the latest salt. |
Closing this since duplicate. The xix will be delivered in the next point release of Salt 2019.2.1 which is near completing final QA, The original issue and fix can be tracked via #51828 |
@dmurphy18 , with all due respect I am quite certain this is not a duplicate of that issue. I was looking at the code in the Here is the line number in the |
More specifically, that issue seems to address the issue with the user wanting to retain newlines, while this issue deals with the user not wanting to add in a trailing newline if one is not already present. Some services require that there be no newline at the end of the config, cookie, etc. file. |
@dmurphy18 please re-open this as this is not a dupe. I've confirmed this is still a bug in the latest. I've hacked on salt long enough to know this is not fixed. This is a separate bug from #51828. |
Good deal - thanks for confirming! 👍 I should be able to get in touch with one of the devs - I'll see if I can poke someone on the side to get a second look before re-reporting. |
Reopened, apologies, thought it was the same issue from a first reading. |
Much appreciated gents. It is hard to maintain such a large project. |
So for this block of code...
@tj90241 like you said, the for loop will always ensure the last line of text, in this case So the behavior of |
bingo. (as long as the |
Cool, I wanted first to make sure we're on the same page about expected behavior. And, although the documentation isn't fully incorrect, I'm going to make it more exhaustive and then address this issue. Thanks for responding @tj90241 |
Alright I think this covers all the cases, see if this change works for you guys. |
lgtm! |
JFTR, faced this one while debugging a case similar to #31709 - the proposed PR seems to fix an inconsistency. |
Description of Issue
The
file.managed
state is said to have acontents_newline
argument which can optionally be specified (asFalse
) to prevent a newline from being appended to the end of the managed file when used in conjunction withcontents
,contents_grains
, orcontents_pillars
. However, in 2018.3.4 and 2019.2, a newline is currently always added -- looks to be an unintended side-effect of #51252.Namely this logic block:
The problem is that
os.linesep
is always applied to the last line as a result of the for loop -- theif
statement does not work as intended because the line will always end inos.linesep
already (unless contents is[]
).Setup
(removing the
watch_in
requisite of course!)Steps to Reproduce Issue
Apply the above state - the managed file should not have a newline at the end... but it will.
Versions Report
The bug also seems to be present in
2019.2
.The text was updated successfully, but these errors were encountered: