zood upgrade worked for the first time. added Kuma check
This commit is contained in:
parent
767380abd0
commit
687e97ab09
7
Makefile
7
Makefile
|
@ -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.sum ]; then echo go.sum exists; else GO111MODULE= go mod init; GO111MODULE= go mod tidy; fi)
|
||||
|
||||
all: goimports gocui
|
||||
all: goimports gocui-debugging
|
||||
# ./zookeeper
|
||||
|
||||
vet:
|
||||
|
@ -21,7 +21,7 @@ gocui: build
|
|||
./zookeeper --gui gocui
|
||||
|
||||
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
|
||||
GO111MODULE=off go build -v -x \
|
||||
|
@ -63,3 +63,6 @@ http-toogle-ZOOD:
|
|||
|
||||
http-list-machines:
|
||||
curl --silent http://localhost:8080/list
|
||||
|
||||
http-uptime:
|
||||
curl --silent http://localhost:8080/uptime
|
||||
|
|
14
doGui.go
14
doGui.go
|
@ -17,12 +17,21 @@ import (
|
|||
|
||||
// refresh the windows & tables the user has open
|
||||
func refresh() {
|
||||
time.Sleep(90 * time.Second)
|
||||
if argv.Verbose {
|
||||
log.Info("zookeeper scan here")
|
||||
}
|
||||
if me.zood != nil {
|
||||
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()
|
||||
return
|
||||
}
|
||||
makeZoodWin()
|
||||
me.zood = makeZoodWin()
|
||||
})
|
||||
|
||||
grid.NewButton("Cluster Events", func() {
|
||||
|
@ -62,6 +71,7 @@ func doGui() {
|
|||
// sit here forever refreshing the GUI
|
||||
for {
|
||||
refresh()
|
||||
time.Sleep(90 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
96
http.go
96
http.go
|
@ -9,7 +9,6 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/protobuf/zoopb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -24,9 +23,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
route := cleanURL(r.URL.Path)
|
||||
|
||||
hostname := r.URL.Query().Get("hostname")
|
||||
flag := r.URL.Query().Get("flag")
|
||||
// packname := r.URL.Query().Get("package")
|
||||
// version := r.URL.Query().Get("version")
|
||||
// flag := r.URL.Query().Get("flag")
|
||||
|
||||
msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte
|
||||
if err != nil {
|
||||
|
@ -43,54 +40,61 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
if route == "/status" {
|
||||
var packs *zoopb.Packages
|
||||
packs = new(zoopb.Packages)
|
||||
if err := packs.Unmarshal(msg); err != nil {
|
||||
log.Info("/status proto.Unmarshal() failed on wire message len", len(msg), "from", hostname)
|
||||
/*
|
||||
if route == "/status" {
|
||||
var packs *zoopb.Packages
|
||||
packs = new(zoopb.Packages)
|
||||
if err := packs.Unmarshal(msg); err != nil {
|
||||
log.Info("/status proto.Unmarshal() failed on wire message len", len(msg), "from", hostname)
|
||||
return
|
||||
}
|
||||
|
||||
log.Info("/status Unmarshal worked with msg len", len(msg), "from", hostname)
|
||||
log.Info("/status hostname", hostname, "has", packs.Len(), "packages installed")
|
||||
fmt.Fprintln(w, "upgrade")
|
||||
return
|
||||
}
|
||||
|
||||
log.Info("/status Unmarshal worked with msg len", len(msg), "from", hostname)
|
||||
log.Info("/status hostname", hostname, "has", packs.Len(), "packages installed")
|
||||
fmt.Fprintln(w, "upgrade")
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
// list out the machines and thier version of zood
|
||||
if route == "/list" {
|
||||
log.HttpMode(w)
|
||||
defer log.HttpMode(nil)
|
||||
loop := me.machines.SortByHostname()
|
||||
for loop.Scan() {
|
||||
m := loop.Next()
|
||||
zood := m.Packages.FindByName("zood")
|
||||
v := me.targets["zood"] // this is the target version
|
||||
if zood == nil {
|
||||
log.Info("machine", m.Hostname, "does not have zood installed")
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("zood version %s vs target version %s on machine %s", zood.Version, v, m.Hostname))
|
||||
/*
|
||||
if route == "/list" {
|
||||
log.HttpMode(w)
|
||||
defer log.HttpMode(nil)
|
||||
loop := me.machines.SortByHostname()
|
||||
for loop.Scan() {
|
||||
m := loop.Next()
|
||||
zood := m.Packages.FindByName("zood")
|
||||
v := me.targets["zood"] // this is the target version
|
||||
if zood == nil {
|
||||
log.Info("machine", m.Hostname, "does not have zood installed")
|
||||
} else {
|
||||
log.Info(fmt.Sprintf("zood version %s vs target version %s on machine %s", zood.Version, v, m.Hostname))
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
if route == "/uptime" {
|
||||
if me.zood == nil {
|
||||
fmt.Fprintf(w, "BAD zood == nil\n")
|
||||
return
|
||||
}
|
||||
var count int
|
||||
var bad int
|
||||
all := me.machines.All()
|
||||
for all.Scan() {
|
||||
m := all.Next()
|
||||
count += 1
|
||||
if findVersion(m, "zood") != me.zood.version {
|
||||
bad += 1
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// toggle logging flags
|
||||
if route == "/flag" {
|
||||
log.HttpMode(w)
|
||||
defer log.HttpMode(nil)
|
||||
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:
|
||||
log.Info("unknown looging flag:", flag)
|
||||
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
|
||||
}
|
||||
|
|
2
main.go
2
main.go
|
@ -37,7 +37,7 @@ func main() {
|
|||
|
||||
me = new(zookeep)
|
||||
me.hostname, _ = os.Hostname()
|
||||
me.pollDelay = 10 * time.Second
|
||||
me.pollDelay = time.Hour
|
||||
me.machines = zoopb.NewMachines()
|
||||
// me.machines2 = zoopb.NewMachines()
|
||||
if err := me.machines.ConfigLoad(); err != nil {
|
||||
|
|
|
@ -55,7 +55,7 @@ func NewWatchdog() {
|
|||
// 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.Scan()
|
||||
|
|
|
@ -16,10 +16,12 @@ import (
|
|||
|
||||
type stdTableWin struct {
|
||||
sync.Mutex
|
||||
win *gadgets.GenericWindow // the machines gui window
|
||||
box *gui.Node // the machines gui parent box widget
|
||||
TB *zoopb.MachinesTable // the machines gui table buffer
|
||||
update bool // if the window should be updated
|
||||
win *gadgets.GenericWindow // the machines gui window
|
||||
box *gui.Node // the machines gui parent box widget
|
||||
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
|
||||
}
|
||||
|
||||
func (w *stdTableWin) Toggle() {
|
||||
|
@ -42,10 +44,24 @@ func makeZoodWin() *stdTableWin {
|
|||
grid.NewButton("save machines.pb", func() {
|
||||
saveMachineState()
|
||||
})
|
||||
grid.NewCheckbox("hide active")
|
||||
grid.NewButton("update", func() {
|
||||
grid.NewButton("show active", func() {
|
||||
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
|
||||
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.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)
|
||||
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.AddMemory()
|
||||
|
@ -103,7 +130,6 @@ func AddMachinesPB(tbox *gui.Node, pb *zoopb.Machines) *zoopb.MachinesTable {
|
|||
return findVersion(m, "zood")
|
||||
})
|
||||
delf := func(m *zoopb.Machine) string {
|
||||
pb.DeleteByHostname(m.Hostname)
|
||||
return "delete"
|
||||
}
|
||||
t.AddButtonFunc("delete", delf)
|
||||
|
|
Loading…
Reference in New Issue