summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-15 11:39:25 -0600
committerJeff Carr <[email protected]>2025-02-15 12:21:32 -0600
commit97f29457dbee65a4404570fd17fd5d0f08e21502 (patch)
treea088ec6ecfc9d5720ff541df05ba6f15189175ec
parent8eed7faa7c123ab64b013f3362be35248a389d03 (diff)
runs and saves configv0.0.28v0.0.27v0.0.26
-rw-r--r--Makefile4
-rw-r--r--machine.go31
2 files changed, 24 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 498b014..3780da9 100644
--- a/Makefile
+++ b/Makefile
@@ -7,8 +7,8 @@ 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 build nogui
- ./zookeeper --version
+all: goimports build
+ ./zookeeper
nogui:
./zookeeper --gui nocui
diff --git a/machine.go b/machine.go
index 999e31b..a902b7d 100644
--- a/machine.go
+++ b/machine.go
@@ -13,21 +13,34 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)
+func rawGetHostname(data []byte) *zoopb.Machine {
+ newm := new(zoopb.Machine)
+ newm.Unmarshal(data)
+ return newm
+}
+
func handleMachine(w http.ResponseWriter, hostname string, data []byte) {
hostname = strings.TrimSpace(hostname)
+ newm := rawGetHostname(data)
+ if newm == nil {
+ log.Info("unmarshal failed on data len =", len(data))
+ }
+ if hostname == newm.Hostname {
+ log.Info("hostname mismatch", hostname, "vs", newm.Hostname)
+ hostname = newm.Hostname
+ }
+
if hostname == "" {
- log.Info("something went wrong. hostname is blank")
+ log.Info("hostname is blank even after unmarshal. data len =", len(data))
+ return
}
log.Info("lookoing for", hostname)
m := me.machines.FindByHostname(hostname)
if m == nil {
- newm := new(zoopb.Machine)
- err := newm.Unmarshal(data)
- if err != nil {
- log.Info("machine Unmarshal() failed", hostname)
- return
- }
- me.machines.Append(newm)
+ am := new(zoopb.Machine)
+ am.Hostname = newm.Hostname
+ am.Memory = newm.Memory
+ me.machines2.Append(am)
return
}
log.Info("not new machine", hostname)
@@ -44,7 +57,7 @@ func updateMachine(u *zoopb.Machine) string {
log.Info("adding new machine", u.Hostname)
me.machines.Append(u)
log.Info("save machines pb file here...")
- // me.machines.ConfigSave()
+ me.machines2.ConfigSave()
return "new"
}
// log.Info("updating machine", m.Hostname)