diff options
| author | Jeff Carr <[email protected]> | 2024-11-01 00:41:00 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-11-01 00:41:00 -0500 |
| commit | c1d86fc324671995ee6dc279c7568bceda1cc910 (patch) | |
| tree | b7ba69757e251da753780cf6a8a8b1e8e60a2d75 /poll.go | |
| parent | 26cd0f7709ba552b98aeee83723612eb5e7009cb (diff) | |
common d.SprintHeader() functions for humans
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'poll.go')
| -rw-r--r-- | poll.go | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -33,16 +33,16 @@ func (h *HyperT) pollHypervisor() { } state := fields[0] name := fields[1] - start := fmt.Sprintf("%-9s %-20.20s", h.pb.Hostname, name) d := me.cluster.FindDropletByName(name) if d == nil { - log.Log(WARN, start, "local defined domain") - log.Log(WARN, start, "local Adding new entry with AddDropletLocal()") - log.Log(WARN, start, "local Adding new entry with AddDropletLocal()") - log.Log(WARN, start, "local Adding new entry with AddDropletLocal()") + log.Log(WARN, name, "local defined domain") + log.Log(WARN, name, "local Adding new entry with AddDropletLocal()") + log.Log(WARN, name, "local Adding new entry with AddDropletLocal()") + log.Log(WARN, name, "local Adding new entry with AddDropletLocal()") me.cluster.AddDropletLocal(name, h.pb.Hostname) return } + start := d.SprintHeader() h.lastDroplets[name] = time.Now() if state == "OFF" { if d.LocalOnly == "" { @@ -57,7 +57,7 @@ func (h *HyperT) pollHypervisor() { log.Log(POLL, start, "STATE:", state, "rest:", fields[2:]) // update the status to ON - d.Current.State = pb.DropletState_ON + d.SetState(pb.DropletState_ON) // set the LastPoll time to now now := time.Now() @@ -106,20 +106,20 @@ func (h *HyperT) pollHypervisor() { } // everthing below here is dumb and needs to be rethought if d.Current.State != pb.DropletState_UNKNOWN { - d.Current.State = pb.DropletState_UNKNOWN + d.SetState(pb.DropletState_UNKNOWN) log.Info("set state UNKNOWN here", name) } if d.Current.State == pb.DropletState_UNKNOWN { if dur > time.Minute*2 { // what this means is the droplet probably wasn't migrated or the migrate failed // where should this be checked? the status needs to be changed to OFF - s := shell.FormatDuration(dur) + s := pb.FormatDuration(dur) log.Info("UNKNOWN state for more than 2 minutes (clearing out ?)", name, s) // it might be safe to set the status to OFF here. not really. this poll needs // to be moved somewhere else. there needs to be a new goroutine not tied to the // hypervisor - d.Current.State = pb.DropletState_OFF + d.SetState(pb.DropletState_OFF) } } } @@ -158,13 +158,13 @@ func uptimeCheck() (bool, string) { unknownList = append(unknownList, d.Hostname) case pb.DropletState_ON: if dur > me.missingDropletTimeout { - log.Info("GOOD STATE MISSING", d.Hostname, hname, shell.FormatDuration(dur)) + log.Info("GOOD STATE MISSING", d.Hostname, hname, pb.FormatDuration(dur)) good = false - d.Current.State = pb.DropletState_UNKNOWN + d.SetState(pb.DropletState_UNKNOWN) failed += 1 continue } - l := shell.FormatDuration(dur) + l := pb.FormatDuration(dur) if l == "" { log.Info("DUR IS EMPTY", dur) missing = append(missing, d) @@ -173,12 +173,12 @@ func uptimeCheck() (bool, string) { working += 1 // log.Info("GOOD STATE ON", d.Hostname, d.hname, "dur =", l) case pb.DropletState_OFF: - log.Info("OFF STATE", d.StartState, d.Hostname, hname, shell.FormatDuration(dur)) + log.Info("OFF STATE", d.StartState, d.Hostname, hname, pb.FormatDuration(dur)) good = false failed += 1 // missing = append(missing, d) default: - log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, shell.FormatDuration(dur)) + log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, pb.FormatDuration(dur)) good = false failed += 1 missing = append(missing, d) @@ -202,7 +202,7 @@ func uptimeCheck() (bool, string) { summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")" } last := time.Since(me.unstable) - s := strings.TrimSpace(shell.FormatDuration(last)) + s := strings.TrimSpace(pb.FormatDuration(last)) if last > me.clusterStableDuration { // the cluster has not been stable for 10 seconds summary += "(stable=" + s + ")" |
