From 46f29b98970d5c6820dbfb3d7ae6a73fe668a9a0 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Thu, 12 Dec 2019 11:47:28 +0100 Subject: [PATCH] HA: Do not use seconds in responsibility check --- ha/ha.go | 2 +- ha/ha_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ha/ha.go b/ha/ha.go index 823cc2e6..e84de150 100644 --- a/ha/ha.go +++ b/ha/ha.go @@ -173,7 +173,7 @@ func (h *HA) checkResponsibility(env *Environment) { return } - if time.Now().Unix()-beat > 15*1000 { + if utils.TimeToMillisecs(time.Now())-beat > 15*1000 { h.logger.Info("Taking over.") // This means there was no instance row match, insert diff --git a/ha/ha_test.go b/ha/ha_test.go index a20fe369..72be9ec1 100644 --- a/ha/ha_test.go +++ b/ha/ha_test.go @@ -101,7 +101,7 @@ func TestHA_checkResponsibility(t *testing.T) { _, err = ha.super.Dbw.SqlExec( mysqlObservers.insertIntoIcingadbInstance, "INSERT INTO icingadb_instance(id, environment_id, heartbeat, responsible, icinga2_version, icinga2_start_time) VALUES (?, ?, ?, 'y', '', 0)", - ha.uid[:], ha.super.EnvId, time.Now().Unix(), + ha.uid[:], ha.super.EnvId, utils.TimeToMillisecs(time.Now()), ) ha.isActive = false