]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/devicehealth: replace SMART data if exists for same DATETIME 54337/head
authorPatrick Donnelly <pdonnell@redhat.com>
Fri, 3 Nov 2023 18:44:38 +0000 (14:44 -0400)
committerPatrick Donnelly <pdonnell@redhat.com>
Mon, 6 Nov 2023 13:40:20 +0000 (08:40 -0500)
Where DATETIME means "seconds since epoch".

Fixes: https://tracker.ceph.com/issues/63433
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
src/pybind/mgr/devicehealth/module.py

index 07768db756565a1341ac75ef8e0a624c463807db..86ea1d280720c58ed0fa5540f135c3fd00ae5cd2 100644 (file)
@@ -502,8 +502,8 @@ CREATE TABLE DeviceHealthMetrics (
 
     def put_device_metrics(self, devid: str, data: Any) -> None:
         SQL = """
-        INSERT INTO DeviceHealthMetrics (devid, raw_smart)
-            VALUES (?, ?);
+        INSERT OR REPLACE INTO DeviceHealthMetrics (devid, raw_smart, time)
+            VALUES (?, ?, strftime('%s', 'now'));
         """
 
         with self._db_lock, self.db: