mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Don't misuse loop as if
This commit is contained in:
parent
afe0a90487
commit
b0354e3503
1 changed files with 6 additions and 8 deletions
|
|
@ -179,19 +179,17 @@ func (h *HA) realize(s *icingaredisv1.IcingaStatus, t *types.UnixMilli, shouldLo
|
|||
return err
|
||||
}
|
||||
takeover := true
|
||||
for rows.Next() {
|
||||
if rows.Next() {
|
||||
instance := &v1.IcingadbInstance{}
|
||||
err := rows.StructScan(instance)
|
||||
if err != nil {
|
||||
h.logger.Errorw("Can't scan currently active instance", zap.Error(err))
|
||||
break
|
||||
} else {
|
||||
if shouldLog {
|
||||
h.logger.Infow("Another instance is active", "instance_id", instance.Id, zap.String("environment", s.Environment), "heartbeat", instance.Heartbeat, zap.Duration("heartbeat_age", time.Since(instance.Heartbeat.Time())))
|
||||
}
|
||||
takeover = false
|
||||
}
|
||||
|
||||
if shouldLog {
|
||||
h.logger.Infow("Another instance is active", "instance_id", instance.Id, zap.String("environment", s.Environment), "heartbeat", instance.Heartbeat, zap.Duration("heartbeat_age", time.Since(instance.Heartbeat.Time())))
|
||||
}
|
||||
takeover = false
|
||||
break
|
||||
}
|
||||
_ = rows.Close()
|
||||
i := v1.IcingadbInstance{
|
||||
|
|
|
|||
Loading…
Reference in a new issue