fixes saltstack/salt#63033 fix file.retention_schedule always reports changes

This commit is contained in:
nicholasmhughes 2022-11-07 19:07:44 -05:00 committed by Megan Wilhite
parent b8468c6a10
commit c1c99cf5f3
3 changed files with 6 additions and 4 deletions

1
changelog/63033.fixed Normal file
View file

@ -0,0 +1 @@
Fix file.retention_schedule always reports changes

View file

@ -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.
@ -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": "",
}
@ -4785,7 +4786,8 @@ def retention_schedule(name, retain, strptime_format=None, timezone=None):
"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"]:
@ -4800,7 +4802,6 @@ def retention_schedule(name, retain, strptime_format=None, timezone=None):
ret["comment"] = "{} backups were removed from {}.\n".format(
len(deletable_files), name
)
ret["changes"] = changes
return ret

View file

@ -135,7 +135,7 @@ def test_retention_schedule():
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",
}