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.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
|
||||||
|
|
14
doGui.go
14
doGui.go
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
96
http.go
96
http.go
|
@ -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,54 +40,61 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if route == "/status" {
|
/*
|
||||||
var packs *zoopb.Packages
|
if route == "/status" {
|
||||||
packs = new(zoopb.Packages)
|
var packs *zoopb.Packages
|
||||||
if err := packs.Unmarshal(msg); err != nil {
|
packs = new(zoopb.Packages)
|
||||||
log.Info("/status proto.Unmarshal() failed on wire message len", len(msg), "from", hostname)
|
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
|
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
|
// list out the machines and thier version of zood
|
||||||
if route == "/list" {
|
/*
|
||||||
log.HttpMode(w)
|
if route == "/list" {
|
||||||
defer log.HttpMode(nil)
|
log.HttpMode(w)
|
||||||
loop := me.machines.SortByHostname()
|
defer log.HttpMode(nil)
|
||||||
for loop.Scan() {
|
loop := me.machines.SortByHostname()
|
||||||
m := loop.Next()
|
for loop.Scan() {
|
||||||
zood := m.Packages.FindByName("zood")
|
m := loop.Next()
|
||||||
v := me.targets["zood"] // this is the target version
|
zood := m.Packages.FindByName("zood")
|
||||||
if zood == nil {
|
v := me.targets["zood"] // this is the target version
|
||||||
log.Info("machine", m.Hostname, "does not have zood installed")
|
if zood == nil {
|
||||||
} else {
|
log.Info("machine", m.Hostname, "does not have zood installed")
|
||||||
log.Info(fmt.Sprintf("zood version %s vs target version %s on machine %s", zood.Version, v, m.Hostname))
|
} 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
|
if bad == 0 {
|
||||||
}
|
fmt.Fprintf(w, "GOOD machine count=(%d) all machines are version %s\n", count, me.zood.version)
|
||||||
|
} else {
|
||||||
// toggle logging flags
|
fmt.Fprintf(w, "BAD machine count=(%d) upgrade=(%d) to %s\n", count, bad, me.zood.version)
|
||||||
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)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -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 {
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -16,10 +16,12 @@ import (
|
||||||
|
|
||||||
type stdTableWin struct {
|
type stdTableWin struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
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
|
||||||
update bool // if the window should be updated
|
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() {
|
func (w *stdTableWin) Toggle() {
|
||||||
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue