]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/snap-schedule: fix deactivate 37415/head
authorJan Fajerski <jfajerski@suse.com>
Fri, 25 Sep 2020 14:16:42 +0000 (16:16 +0200)
committerJan Fajerski <jfajerski@suse.com>
Wed, 14 Oct 2020 07:22:09 +0000 (09:22 +0200)
This commit adds another argument to get_db_schedules in order to able
to filter not only by the repeat column (schedule period in seconds,
used for snapshotting) but also by the schedule column (the user facing
schedule period, string like 3h).

Fixes: https://tracker.ceph.com/issues/47515
Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/pybind/mgr/snap_schedule/fs/schedule.py
src/pybind/mgr/snap_schedule/fs/schedule_client.py

index 019d28caa2d3946c4847a465220de29c8e649983..9b89f476e26ccbd58235419fc4e6e4651c4f36f2 100644 (file)
@@ -207,12 +207,18 @@ class Schedule(object):
     GET_SCHEDULES = PROTO_GET_SCHEDULES + ' s.path = ?'''
 
     @classmethod
-    def get_db_schedules(cls, path, db, fs, repeat=None, start=None):
+    def get_db_schedules(cls, path, db, fs,
+                         schedule=None,
+                         start=None,
+                         repeat=None):
         query = cls.GET_SCHEDULES
         data: Tuple[Any, ...] = (path,)
         if repeat:
             query += ' AND sm.repeat = ?'
             data += (repeat,)
+        if schedule:
+            query += ' AND sm.schedule = ?'
+            data += (schedule,)
         if start:
             query += ' AND sm.start = ?'
             data += (start,)
index 5c7cb0bd01d2b5975237e6af4192136183a446c6..12298c1f97e3d1bc8ddeefd7d210b9510471b854 100644 (file)
@@ -175,8 +175,8 @@ class SnapSchedClient(CephfsClient):
             sched = Schedule.get_db_schedules(path,
                                               db,
                                               fs_name,
-                                              repeat,
-                                              start)[0]
+                                              repeat=repeat,
+                                              start=start)[0]
             time = datetime.now(timezone.utc)
             with open_filesystem(self, fs_name) as fs_handle:
                 snap_ts = time.strftime(SNAPSHOT_TS_FORMAT)
@@ -244,9 +244,9 @@ class SnapSchedClient(CephfsClient):
         self.store_schedule_db(sched.fs)
 
     @updates_schedule_db
-    def rm_snap_schedule(self, fs, path, repeat, start):
+    def rm_snap_schedule(self, fs, path, schedule, start):
         db = self.get_schedule_db(fs)
-        Schedule.rm_schedule(db, path, repeat, start)
+        Schedule.rm_schedule(db, path, schedule, start)
 
     @updates_schedule_db
     def add_retention_spec(self,
@@ -273,13 +273,17 @@ class SnapSchedClient(CephfsClient):
         Schedule.rm_retention(db, path, retention_spec)
 
     @updates_schedule_db
-    def activate_snap_schedule(self, fs, path, repeat, start):
+    def activate_snap_schedule(self, fs, path, schedule, start):
         db = self.get_schedule_db(fs)
-        schedules = Schedule.get_db_schedules(path, db, fs, repeat, start)
+        schedules = Schedule.get_db_schedules(path, db, fs,
+                                              schedule=schedule,
+                                              start=start)
         [s.set_active(db) for s in schedules]
 
     @updates_schedule_db
-    def deactivate_snap_schedule(self, fs, path, repeat, start):
+    def deactivate_snap_schedule(self, fs, path, schedule, start):
         db = self.get_schedule_db(fs)
-        schedules = Schedule.get_db_schedules(path, db, fs, repeat, start)
+        schedules = Schedule.get_db_schedules(path, db, fs,
+                                              schedule=schedule,
+                                              start=start)
         [s.set_inactive(db) for s in schedules]