Explict mark utc time
diff --git a/staffeln/conductor/backup.py b/staffeln/conductor/backup.py
index e34d681..f3deff4 100755
--- a/staffeln/conductor/backup.py
+++ b/staffeln/conductor/backup.py
@@ -1,5 +1,5 @@
import collections
-from datetime import timedelta
+from datetime import timedelta, timezone
import staffeln.conf
from openstack.exceptions import HttpException as OpenstackHttpException
@@ -245,8 +245,8 @@
if backup is None:
LOG.info(
_(
- "Backup %s is not existing in Openstack."
- "Or cinder-backup is not existing in the cloud."
+ "Backup %s is not existing in Openstack "
+ "or cinder-backup is not existing in the cloud."
% backup_object.backup_id
)
)
@@ -354,7 +354,7 @@
backups = self.get_backups(
filters={
"volume_id__eq": volume_id,
- "created_at__gt": threshold_strtime.astimezone(),
+ "created_at__gt": threshold_strtime.astimezone(timezone.utc),
}
)
if backups:
diff --git a/staffeln/conductor/manager.py b/staffeln/conductor/manager.py
index 34f1af3..9720650 100755
--- a/staffeln/conductor/manager.py
+++ b/staffeln/conductor/manager.py
@@ -1,6 +1,6 @@
import threading
import time
-from datetime import timedelta
+from datetime import timedelta, timezone
import cotyledon
import staffeln.conf
@@ -133,7 +133,7 @@
report_period = CONF.conductor.report_period
threshold_strtime = timeutils.utcnow() - timedelta(seconds=report_period)
- filters = {"created_at__gt": threshold_strtime.astimezone()}
+ filters = {"created_at__gt": threshold_strtime.astimezone(timezone.utc)}
report_tss = objects.ReportTimestamp.list( # pylint: disable=E1120
context=self.ctx, filters=filters
)
@@ -145,7 +145,7 @@
# Purge records that live longer than 10 report cycles
threshold_strtime = timeutils.utcnow() - timedelta(seconds=report_period*10)
- filters = {"created_at__lt": threshold_strtime.astimezone()}
+ filters = {"created_at__lt": threshold_strtime.astimezone(timezone.utc)}
old_report_tss = objects.ReportTimestamp.list( # pylint: disable=E1120
context=self.ctx, filters=filters
)
@@ -213,8 +213,8 @@
self.controller.hard_remove_volume_backup(retention_backup)
def is_retention(self, backup):
- now = timeutils.utcnow()
- backup_age = now - backup.created_at
+ now = timeutils.utcnow().astimezone(timezone.utc)
+ backup_age = now - backup.created_at.astimezone(timezone.utc)
# see if need to be delete.
if backup.instance_id in self.instance_retention_map:
retention_time = now - self.get_time_from_str(
@@ -240,7 +240,7 @@
# get the threshold time
self.threshold_strtime = self.get_time_from_str(
CONF.conductor.retention_time
- )
+ ).astimezone(timezone.utc)
self.instance_retention_map = (
self.controller.collect_instance_retention_map()
)