From: Patrick Donnelly Date: Fri, 3 Nov 2023 18:44:38 +0000 (-0400) Subject: pybind/mgr/devicehealth: replace SMART data if exists for same DATETIME X-Git-Tag: testing/wip-pdonnell-testing-20240430.123648-reef-debug~211^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=272ca4d82d5b5ed0bf45efab12ef1c033d0ccf27;p=ceph-ci.git pybind/mgr/devicehealth: replace SMART data if exists for same DATETIME Where DATETIME means "seconds since epoch". Fixes: https://tracker.ceph.com/issues/63433 Signed-off-by: Patrick Donnelly (cherry picked from commit 1a13e7407a043b151d02d6d65ad37d87788fa3a5) --- diff --git a/src/pybind/mgr/devicehealth/module.py b/src/pybind/mgr/devicehealth/module.py index 07768db7565..86ea1d28072 100644 --- a/src/pybind/mgr/devicehealth/module.py +++ b/src/pybind/mgr/devicehealth/module.py @@ -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: