]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
snap-schedule: count retained snapshots per retention policy
authorJan Fajerski <jfajersk@redhat.com>
Mon, 23 Aug 2021 13:15:21 +0000 (15:15 +0200)
committerJan Fajerski <jfajersk@redhat.com>
Tue, 24 Aug 2021 10:33:34 +0000 (12:33 +0200)
Before this commit the length of the already-retained snapshots
terminated the loop. This fails when muliple retention policies are set.

Fixes: https://tracker.ceph.com/issues/52388
Signed-off-by: Jan Fajerski <jfajersk@redhat.com>
src/pybind/mgr/snap_schedule/fs/schedule_client.py

index 84950d399249f318791fe0059e74345548470fe2..dc2e6e7151c090aafb888e9281931d98dab016e6 100644 (file)
@@ -90,6 +90,7 @@ def get_prune_set(candidates: Set[Tuple[cephfs.DirEntry, datetime]],
         if not period_count:
             continue
         last = None
+        kept_for_this_period = 0
         for snap in sorted(candidates, key=lambda x: x[0].d_name,
                            reverse=True):
             snap_ts = snap[1].strftime(date_pattern)
@@ -99,7 +100,8 @@ def get_prune_set(candidates: Set[Tuple[cephfs.DirEntry, datetime]],
                     log.debug((f'keeping {snap[0].d_name} due to '
                                f'{period_count}{period}'))
                     keep.append(snap)
-                    if len(keep) == period_count:
+                    kept_for_this_period += 1
+                    if kept_for_this_period == period_count:
                         log.debug(('found enough snapshots for '
                                    f'{period_count}{period}'))
                         break