From d2d6c6bf5cb39621ae4f843501a5c01a020e0bd6 Mon Sep 17 00:00:00 2001 From: meow Date: Mon, 30 Dec 2019 15:30:26 +0500 Subject: [PATCH] Use UTC time for heartbeat mechanism --- ucloud/common/host.py | 4 ++-- ucloud/scheduler/main.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ucloud/common/host.py b/ucloud/common/host.py index 191a2c0..01e2091 100644 --- a/ucloud/common/host.py +++ b/ucloud/common/host.py @@ -26,13 +26,13 @@ class HostEntry(SpecificEtcdEntryBase): def update_heartbeat(self): self.status = HostStatus.alive - self.last_heartbeat = time.strftime("%Y-%m-%d %H:%M:%S") + self.last_heartbeat = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S") def is_alive(self): last_heartbeat = datetime.strptime( self.last_heartbeat, "%Y-%m-%d %H:%M:%S" ) - delta = datetime.now() - last_heartbeat + delta = datetime.utcnow() - last_heartbeat if delta.total_seconds() > 60: return False return True diff --git a/ucloud/scheduler/main.py b/ucloud/scheduler/main.py index 7ee75e0..051b338 100755 --- a/ucloud/scheduler/main.py +++ b/ucloud/scheduler/main.py @@ -8,7 +8,6 @@ from ucloud.common.request import RequestEntry, RequestType from ucloud.shared import shared from ucloud.settings import settings from .helper import ( - get_suitable_host, dead_host_mitigation, dead_host_detection, assign_host,