forked from uncloud/uncloud
Use UTC time for heartbeat mechanism
This commit is contained in:
parent
9963e9c62d
commit
d2d6c6bf5c
2 changed files with 2 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue