Skip to content
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

Fix file.retention_schedule always reports changes #63034

Merged
Merged
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
1 change: 1 addition & 0 deletions changelog/63033.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix file.retention_schedule always reports changes
7 changes: 4 additions & 3 deletions salt/states/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4609,6 +4609,7 @@ def retention_schedule(name, retain, strptime_format=None, timezone=None):
Apply retention scheduling to backup storage directory.

.. versionadded:: 2016.11.0
.. versionchanged:: 3006.0

:param name:
The filesystem path to the directory containing backups to be managed.
Expand Down Expand Up @@ -4671,7 +4672,7 @@ def retention_schedule(name, retain, strptime_format=None, timezone=None):
name = os.path.expanduser(name)
ret = {
"name": name,
"changes": {"retained": [], "deleted": [], "ignored": []},
"changes": {},
"result": True,
"comment": "",
}
Expand Down Expand Up @@ -4785,7 +4786,8 @@ def get_first_n_at_depth(fwt, depth, n):
"deleted": deletable_files,
"ignored": sorted(list(ignored_files), reverse=True),
}
ret["changes"] = changes
if deletable_files:
ret["changes"] = changes

# TODO: track and report how much space was / would be reclaimed
if __opts__["test"]:
Expand All @@ -4800,7 +4802,6 @@ def get_first_n_at_depth(fwt, depth, n):
ret["comment"] = "{} backups were removed from {}.\n".format(
len(deletable_files), name
)
ret["changes"] = changes

return ret

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def lstat_side_effect(path):
def run_checks(isdir=mock_t, strptime_format=None, test=False):
expected_ret = {
"name": fake_name,
"changes": {"retained": [], "deleted": [], "ignored": []},
"changes": {},
"result": True,
"comment": "Name provided to file.retention must be a directory",
}
Expand Down