zood upgrade worked for the first time. added Kuma check

This commit is contained in:
Jeff Carr 2025-03-12 15:10:49 -05:00
parent 767380abd0
commit 687e97ab09
6 changed files with 104 additions and 61 deletions

View File

@ -7,7 +7,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
# REDOMOD = $(shell if [ -e go.mod ]; then echo go.mod; else echo no go mod; fi) # REDOMOD = $(shell if [ -e go.mod ]; then echo go.mod; else echo no go mod; fi)
REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= go mod init; GO111MODULE= go mod tidy; fi) REDOMOD = $(shell if [ -e go.sum ]; then echo go.sum exists; else GO111MODULE= go mod init; GO111MODULE= go mod tidy; fi)
all: goimports gocui all: goimports gocui-debugging
# ./zookeeper # ./zookeeper
vet: vet:
@ -21,7 +21,7 @@ gocui: build
./zookeeper --gui gocui ./zookeeper --gui gocui
gocui-debugging: build gocui-debugging: build
./zookeeper --gui gocui >/tmp/forge.log 2>&1 ./zookeeper --gui gocui --gui-file ~/go/src/go.wit.com/toolkits/gocui/gocui.so >/tmp/forge.log 2>&1
build: goimports vet build: goimports vet
GO111MODULE=off go build -v -x \ GO111MODULE=off go build -v -x \
@ -63,3 +63,6 @@ http-toogle-ZOOD:
http-list-machines: http-list-machines:
curl --silent http://localhost:8080/list curl --silent http://localhost:8080/list
http-uptime:
curl --silent http://localhost:8080/uptime

View File

@ -17,12 +17,21 @@ import (
// refresh the windows & tables the user has open // refresh the windows & tables the user has open
func refresh() { func refresh() {
time.Sleep(90 * time.Second)
if argv.Verbose { if argv.Verbose {
log.Info("zookeeper scan here") log.Info("zookeeper scan here")
} }
if me.zood != nil { if me.zood != nil {
me.zood.doMachinesUpgradeTable(me.machines) me.zood.doMachinesUpgradeTable(me.machines)
all := me.machines.All()
for all.Scan() {
m := all.Next()
if me.hostname == m.Hostname {
// this is me! This is the version of zood that should be installed everywhere
v := findVersion(m, "zood")
me.zood.version = v
me.zood.versionL.SetText(v)
}
}
} }
} }
@ -52,7 +61,7 @@ func doGui() {
me.zood.Toggle() me.zood.Toggle()
return return
} }
makeZoodWin() me.zood = makeZoodWin()
}) })
grid.NewButton("Cluster Events", func() { grid.NewButton("Cluster Events", func() {
@ -62,6 +71,7 @@ func doGui() {
// sit here forever refreshing the GUI // sit here forever refreshing the GUI
for { for {
refresh() refresh()
time.Sleep(90 * time.Second)
} }
} }

42
http.go
View File

@ -9,7 +9,6 @@ import (
"net/http" "net/http"
"strings" "strings"
"go.wit.com/lib/protobuf/zoopb"
"go.wit.com/log" "go.wit.com/log"
) )
@ -24,9 +23,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
route := cleanURL(r.URL.Path) route := cleanURL(r.URL.Path)
hostname := r.URL.Query().Get("hostname") hostname := r.URL.Query().Get("hostname")
flag := r.URL.Query().Get("flag") // flag := r.URL.Query().Get("flag")
// packname := r.URL.Query().Get("package")
// version := r.URL.Query().Get("version")
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
if err != nil { if err != nil {
@ -43,6 +40,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
/*
if route == "/status" { if route == "/status" {
var packs *zoopb.Packages var packs *zoopb.Packages
packs = new(zoopb.Packages) packs = new(zoopb.Packages)
@ -56,8 +54,10 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "upgrade") fmt.Fprintln(w, "upgrade")
return return
} }
*/
// list out the machines and thier version of zood // list out the machines and thier version of zood
/*
if route == "/list" { if route == "/list" {
log.HttpMode(w) log.HttpMode(w)
defer log.HttpMode(nil) defer log.HttpMode(nil)
@ -74,23 +74,27 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
} }
return return
} }
*/
// toggle logging flags if route == "/uptime" {
if route == "/flag" { if me.zood == nil {
log.HttpMode(w) fmt.Fprintf(w, "BAD zood == nil\n")
defer log.HttpMode(nil) return
log.Info("going to toggle flag:", flag)
switch flag {
case "ZOOD":
if ZOOD.Enabled() {
log.Log(NOW, "toogle ZOOD false")
ZOOD.SetBool(false)
} else {
log.Log(NOW, "toogle ZOOD true")
ZOOD.SetBool(true)
} }
default: var count int
log.Info("unknown looging flag:", flag) var bad int
all := me.machines.All()
for all.Scan() {
m := all.Next()
count += 1
if findVersion(m, "zood") != me.zood.version {
bad += 1
}
}
if bad == 0 {
fmt.Fprintf(w, "GOOD machine count=(%d) all machines are version %s\n", count, me.zood.version)
} else {
fmt.Fprintf(w, "BAD machine count=(%d) upgrade=(%d) to %s\n", count, bad, me.zood.version)
} }
return return
} }

View File

@ -37,7 +37,7 @@ func main() {
me = new(zookeep) me = new(zookeep)
me.hostname, _ = os.Hostname() me.hostname, _ = os.Hostname()
me.pollDelay = 10 * time.Second me.pollDelay = time.Hour
me.machines = zoopb.NewMachines() me.machines = zoopb.NewMachines()
// me.machines2 = zoopb.NewMachines() // me.machines2 = zoopb.NewMachines()
if err := me.machines.ConfigLoad(); err != nil { if err := me.machines.ConfigLoad(); err != nil {

View File

@ -55,7 +55,7 @@ func NewWatchdog() {
// log.Info("know about machine", m.Hostname, "zood version", zood.Version) // log.Info("know about machine", m.Hostname, "zood version", zood.Version)
} }
} }
log.Info("zookeeper has", counter, "machines. Current time:", t) log.Info("hour watchdog:", counter, "machines. Current time:", t)
// h.pollHypervisor() // h.pollHypervisor()
// h.Scan() // h.Scan()

View File

@ -19,6 +19,8 @@ type stdTableWin struct {
win *gadgets.GenericWindow // the machines gui window win *gadgets.GenericWindow // the machines gui window
box *gui.Node // the machines gui parent box widget box *gui.Node // the machines gui parent box widget
TB *zoopb.MachinesTable // the machines gui table buffer TB *zoopb.MachinesTable // the machines gui table buffer
version string // the current zood version
versionL *gui.Node // label widget to display the current zood version
update bool // if the window should be updated update bool // if the window should be updated
} }
@ -42,10 +44,24 @@ func makeZoodWin() *stdTableWin {
grid.NewButton("save machines.pb", func() { grid.NewButton("save machines.pb", func() {
saveMachineState() saveMachineState()
}) })
grid.NewCheckbox("hide active") grid.NewButton("show active", func() {
grid.NewButton("update", func() {
zood.doMachinesUpgradeTable(me.machines) zood.doMachinesUpgradeTable(me.machines)
}) })
grid.NewButton("refresh", func() {
refresh()
})
zood.versionL = grid.NewLabel("scan")
grid.NewButton("show out of date", func() {
found := zoopb.NewMachines()
all := me.machines.All()
for all.Scan() {
m := all.Next()
if findVersion(m, "zood") != me.zood.version {
found.Append(m)
}
}
zood.doMachinesUpgradeTable(found)
})
// make a box at the bottom of the window for the protobuf table // make a box at the bottom of the window for the protobuf table
zood.box = zood.win.Bottom.Box().SetProgName("TBOX") zood.box = zood.win.Bottom.Box().SetProgName("TBOX")
@ -86,11 +102,22 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
t.NewUuid() t.NewUuid()
t.SetParent(tbox) t.SetParent(tbox)
f := func(m *zoopb.Machine) string { upbut := t.AddButtonFunc("upgrade", func(m *zoopb.Machine) string {
if me.zood != nil {
mver := findVersion(m, "zood")
if mver == me.zood.version {
return ""
} else {
// log.Info("machine mismatch", m.Hostname, mver, me.zood.version)
}
}
// log.Info("machine =", m.Hostname) // log.Info("machine =", m.Hostname)
return "now" return "now"
})
upbut.Custom = func(m *zoopb.Machine) {
log.Info("Triggering machine", m.Hostname, "to upgrade zood")
m.Upgrade = true
} }
t.AddButtonFunc("upgrade", f)
t.AddHostname() t.AddHostname()
t.AddMemory() t.AddMemory()
@ -103,7 +130,6 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
return findVersion(m, "zood") return findVersion(m, "zood")
}) })
delf := func(m *zoopb.Machine) string { delf := func(m *zoopb.Machine) string {
pb.DeleteByHostname(m.Hostname)
return "delete" return "delete"
} }
t.AddButtonFunc("delete", delf) t.AddButtonFunc("delete", delf)