Fix file.managed omitting mode from changes when creating a file - #70084
Fix file.managed omitting mode from changes when creating a file#70084HarnageaGabriel wants to merge 1 commit into
Conversation
|
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey. There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
check_file_meta() had two early-return points that fired when a
target file does not yet exist (lstats falsy). Both skipped the
mode/user/group comparison block entirely, so file.managed only
ever reported {'newfile': name} or a diff on creation — never the
mode (or user/group) being applied. Existing-file mode changes were
already reported correctly.
Report the requested mode/user/group directly on the new-file paths
(guarded the same way as the existing-file case, skipped on
Windows), since there is no prior state to diff against.
Fixes saltstack#69969
cf40ea9 to
b860413
Compare
Summary
check_file_meta()insalt/modules/file.pyhas two early-return points that fire when the target file does not yet exist (lstatsfalsy). Both skipped the entire mode/user/group comparison block, sofile.managedonly ever reported{'newfile': name}(test=True) or a diff (real run) when creating a file — never the mode being applied. When the file already existed, mode/user/group changes were reported correctly.mode: '0600'vs an unspecified umask-derived mode produce byte-identicalchanges).mode/user/groupdirectly (there's nothing to diff against), guarded the same way as the existing-file case (skipped on Windows). Both early-return points are updated so behavior is consistent regardless ofnew_file_diff.Fixes #69969
Test plan
tests/pytests/unit/modules/file/test_file_check.pycovering a nonexistent target path withmode/user/groupspecified, for bothnew_file_diff=True/False, and for theignore_ordering/tuple-return path.changelog/69969.fixed.md.Note: ran
pytest tests/pytests/unit/modules/file/test_file_check.pyon Windows; the OS-gated tests (skip_on_windows) skip there since mode/user/group aren't applicable on Windows — the fix's logic was additionally verified directly againstcheck_file_meta()withsalt.utils.platform.is_windows()patched toFalse, confirming the new/existing-file paths behave as expected.🤖 Generated with Claude Code