]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerLaura Paduano <lpaduano@suse.com>
Wed, 6 Oct 2021 14:13:28 +0000 (16:13 +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>
(cherry picked from commit 853d97bbae0c4082b7d6fda7e191df7c246db10f)

 Conflicts:
src/pybind/mgr/snap_schedule/fs/schedule_client.py
- resolved conflict between 89-91

src/pybind/mgr/snap_schedule/fs/schedule_client.py

index f02d94cc5b6fea97156c76f1adf5dcda0f88e390..bb5bcf17f792718bae51db4497ef11368e5f3660 100644 (file)
@@ -79,6 +79,7 @@ def get_prune_set(candidates, retention):
         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)
@@ -87,8 +88,10 @@ def get_prune_set(candidates, retention):
                 if snap not in keep:
                     log.debug(f'keeping {snap[0].d_name} due to {period_count}{period}')
                     keep.append(snap)
-                    if len(keep) == period_count:
-                        log.debug(f'found enough snapshots for {period_count}{period}')
+                    kept_for_this_period += 1
+                    if kept_for_this_period == period_count:
+                        log.debug(('found enough snapshots for '
+                                   f'{period_count}{period}'))
                         break
     if len(keep) > MAX_SNAPS_PER_PATH:
         log.info(f'Would keep more then {MAX_SNAPS_PER_PATH}, pruning keep set')