summaryrefslogtreecommitdiff
path: root/roles
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2021-05-20 12:38:57 +0200
committerChristian Pointner <equinox@spreadspace.org>2021-05-20 12:38:57 +0200
commiteb9f54b296b8a2c0776babddff5cfe2e2febea3b (patch)
tree57d57040703953a00d3b1e31ed92700ffb4f3e18 /roles
parentsyncoid/autosuspend: tweak timing a little (diff)
syncoid autosuspend: improve log out put and timer accuracy
Diffstat (limited to 'roles')
-rw-r--r--roles/storage/zfs/syncoid/templates/autosuspend.py.j213
-rw-r--r--roles/storage/zfs/syncoid/templates/autosuspend.timer.j21
-rw-r--r--roles/storage/zfs/syncoid/templates/pull.timer.j21
3 files changed, 13 insertions, 2 deletions
diff --git a/roles/storage/zfs/syncoid/templates/autosuspend.py.j2 b/roles/storage/zfs/syncoid/templates/autosuspend.py.j2
index 3dd893b2..58752328 100644
--- a/roles/storage/zfs/syncoid/templates/autosuspend.py.j2
+++ b/roles/storage/zfs/syncoid/templates/autosuspend.py.j2
@@ -56,7 +56,7 @@ class AutoSuspender(object):
try:
return datetime.datetime.fromtimestamp(int(props['NextElapseUSecRealtime']) / 1000000)
except ValueError:
- return datetime.datetime.now()
+ return None
def check(self):
result = True
@@ -71,6 +71,11 @@ class AutoSuspender(object):
timers = self._get_syncoid_timers()
for timer in timers:
next = self._get_timer_next_elapse(timer[1])
+ if next == None:
+ print(" [NO] the next elapse of timer '%s' is invalid, assuming the unit is currently active" % (timer[0]))
+ result = False
+ continue
+
until = next - datetime.datetime.now()
if(until < datetime.timedelta(minutes=10)):
print(" [NO] timer '%s' elapses in less then 10 Minutes -> %s (%s)" % (timer[0], next, until))
@@ -85,7 +90,11 @@ class AutoSuspender(object):
if not manager.CanSuspend():
print("suspending is not possible!")
return
- manager.Suspend(False)
+ try:
+ manager.Suspend(False)
+ except dbus.exceptions.DBusException:
+ print("ERR: %s" % error)
+ return None
if __name__ == "__main__":
diff --git a/roles/storage/zfs/syncoid/templates/autosuspend.timer.j2 b/roles/storage/zfs/syncoid/templates/autosuspend.timer.j2
index 44413114..fee94905 100644
--- a/roles/storage/zfs/syncoid/templates/autosuspend.timer.j2
+++ b/roles/storage/zfs/syncoid/templates/autosuspend.timer.j2
@@ -3,6 +3,7 @@ Description=automatic system suspender for syncoid-based backups
[Timer]
OnCalendar=*-*-* *:04/10:30
+AccuracySec=10s
[Install]
WantedBy=timers.target
diff --git a/roles/storage/zfs/syncoid/templates/pull.timer.j2 b/roles/storage/zfs/syncoid/templates/pull.timer.j2
index cc252854..bcbb1a28 100644
--- a/roles/storage/zfs/syncoid/templates/pull.timer.j2
+++ b/roles/storage/zfs/syncoid/templates/pull.timer.j2
@@ -3,6 +3,7 @@ Description=syncoid-based backup for {{ item.key }}
[Timer]
OnCalendar={{ item.value.periodic.schedule }}
+AccuracySec=10s
WakeSystem={{ zfs_syncoid_autosuspend | ternary('true', 'false') }}
[Install]