Skip to content

Commit

Permalink
fixes saltstack#63033 fix file.retention_schedule always reports changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasmhughes committed Nov 8, 2022
1 parent 29812c3 commit 7bbf003
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
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
2 changes: 1 addition & 1 deletion tests/pytests/unit/states/file/test_retention_schedule.py
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

0 comments on commit 7bbf003

Please sign in to comment.