From: Jan Fajerski Date: Fri, 25 Sep 2020 14:16:42 +0000 (+0200) Subject: pybind/mgr/snap-schedule: fix deactivate X-Git-Tag: v16.1.0~761^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0c32bfdb766ada1c626108911ec3bacfd3f9af50;p=ceph.git pybind/mgr/snap-schedule: fix deactivate 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 --- diff --git a/src/pybind/mgr/snap_schedule/fs/schedule.py b/src/pybind/mgr/snap_schedule/fs/schedule.py index 019d28caa2d..9b89f476e26 100644 --- a/src/pybind/mgr/snap_schedule/fs/schedule.py +++ b/src/pybind/mgr/snap_schedule/fs/schedule.py @@ -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,) diff --git a/src/pybind/mgr/snap_schedule/fs/schedule_client.py b/src/pybind/mgr/snap_schedule/fs/schedule_client.py index 5c7cb0bd01d..12298c1f97e 100644 --- a/src/pybind/mgr/snap_schedule/fs/schedule_client.py +++ b/src/pybind/mgr/snap_schedule/fs/schedule_client.py @@ -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]