diff --git a/ha/ha.go b/ha/ha.go index 32f25a9c..503dcdca 100644 --- a/ha/ha.go +++ b/ha/ha.go @@ -214,7 +214,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