Content-Length: 384459 | pFad | http://github.com/saltstack/salt/pull/68189/commits/98ce2f97e9ff04cc46e9b10aca7d7c102942f7bb

49 wrong changes message fixed by bertdawg76 · Pull Request #68189 · saltstack/salt · GitHub
Skip to content

wrong changes message fixed #68189

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
wrong changes message fixed
  • Loading branch information
bertdawg76 committed Jul 16, 2025
commit 98ce2f97e9ff04cc46e9b10aca7d7c102942f7bb
1 change: 1 addition & 0 deletions changelog/68052.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this fixes when a file is managed, and the same file is cleaned, an incorrect message is displayed saying "removed: Removed due to clean" when the file isn't actually removed
2 changes: 1 addition & 1 deletion salt/states/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ def _check_directory(

def _check_changes(fname):
path = os.path.join(root, fname)
if path in keep:
if any(path in s for s in keep):
return {}
else:
if not salt.utils.stringutils.check_include_exclude(
Expand Down
60 changes: 60 additions & 0 deletions tests/pytests/functional/states/file/test_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import salt.utils.files
import salt.utils.path
import salt.utils.platform
import salt.utils.win_dacl
import salt.utils.win_functions

pytestmark = [
Expand Down Expand Up @@ -290,6 +291,65 @@ def test_directory_clean_require_in(modules, tmp_path, state_tree):
assert wrong_file.exists() is False


def test_directory_clean_require_in_good_message(modules, tmp_path, state_tree):
"""
file.directory test with clean=True and require_in file,
the comment cannot be "removed": "Removed due to clean"
"""
name = tmp_path / "b-directory"
name.mkdir()
if IS_WINDOWS:
principal = salt.utils.win_functions.get_current_user()
salt.utils.win_dacl.set_owner(obj_name=str(name), principal=principal)
dir = name / "one"
dir.mkdir()
good_file = dir / "good-file"
good_file.write_text("good")

assert good_file.exists()
assert good_file.is_file()

assert name.exists()
assert name.is_dir()

assert dir.exists()
assert dir.is_dir()

sls_contents = """
some_dir:
file.directory:
- name: {name}
- clean: true
{good_file}:
file.managed:
- require_in:
- file: some_dir
""".format(
name=name, good_file=good_file
)

with pytest.helpers.temp_file("clean-require-in.sls", sls_contents, state_tree):
ret = modules.state.sls("clean-require-in")
expected_file = (
f"File {good_file} exists with proper permissions. No changes made."
)
for state_run in ret:
print("changes", state_run.changes)
if IS_WINDOWS:
if state_run.changes:
expected_dir = f"Directory {name} updated"
else:
expected_dir = f"Directory {name} is in the correct state"
else:
expected_dir = f"The directory {name} is in the correct state"
assert dir.exists()
assert good_file.exists()
assert good_file.read_text() == "good"
assert (
state_run.comment == expected_file or state_run.comment == expected_dir
)


def test_directory_clean_require_in_with_id(modules, tmp_path, state_tree):
"""
file.directory test with clean=True and require_in file with an ID
Expand Down
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/saltstack/salt/pull/68189/commits/98ce2f97e9ff04cc46e9b10aca7d7c102942f7bb

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy