diff options
| author | Jeff Carr <[email protected]> | 2025-02-22 17:45:50 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-02-22 17:45:50 -0600 |
| commit | 32e27530075a09f5c3b82ca6cbb83a01e34cb24c (patch) | |
| tree | bf1ad3f04ef77b2425385a4261e36d95909b6988 | |
| parent | 9f9a52312e6e9538e7ec4c0eefbe46aace352fd3 (diff) | |
switch virtbuf to virtpbv0.2.36
| -rw-r--r-- | doGui.go | 4 | ||||
| -rw-r--r-- | dump.go | 8 | ||||
| -rw-r--r-- | event.go | 4 | ||||
| -rw-r--r-- | http.go | 6 | ||||
| -rw-r--r-- | importDomain.go | 6 | ||||
| -rw-r--r-- | main.go | 12 | ||||
| -rw-r--r-- | poll.go | 38 | ||||
| -rw-r--r-- | start.go | 8 | ||||
| -rw-r--r-- | structs.go | 30 | ||||
| -rw-r--r-- | validate.go | 36 |
10 files changed, 76 insertions, 76 deletions
@@ -11,7 +11,7 @@ import ( "go.wit.com/gui" "go.wit.com/lib/gadgets" - "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) @@ -81,7 +81,7 @@ func findVersion(m *zoopb.Machine, pkgname string) string { return zood.Version } -func makeDropletsWindow(pb *virtbuf.Droplets) *genericWindow { +func makeDropletsWindow(pb *virtpb.Droplets) *genericWindow { win := initGenericWindow("Droplets registered with Virtigo", "Buttons of things") grid := win.group.RawGrid() grid.NewButton("List", func() { @@ -5,7 +5,7 @@ import ( "net/http" "time" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/log" ) @@ -43,12 +43,12 @@ func dumpDroplets(w http.ResponseWriter, full bool) { } header += d.Hostname - if d.Current.State == pb.DropletState_ON { + if d.Current.State == virtpb.DropletState_ON { // everything is as it should be with this vm fmt.Fprintln(w, header) continue } - if d.StartState == pb.DropletState_ON { + if d.StartState == virtpb.DropletState_ON { // this is supposed to be ON and needs to be turned on fmt.Fprintln(w, header, "(should be on). todo: start() here") continue @@ -78,7 +78,7 @@ func dumpHypervisors(w http.ResponseWriter) { var totalUnknownDroplets int for _, h := range me.hypers { dur := time.Since(h.lastpoll) - tmp := pb.FormatDuration(dur) + tmp := virtpb.FormatDuration(dur) fmt.Fprintln(w, h.pb.Hostname, "killcount =", h.killcount, "lastpoll:", tmp) for name, _ := range h.lastDroplets { totalDroplets += 1 @@ -5,7 +5,7 @@ import ( "time" "go.wit.com/lib/gui/shell" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/log" ) @@ -27,7 +27,7 @@ func (h *HyperT) RestartVirtigod() { // this must be bool in string because accumulated output is sometimes // written to STDOUT, sometimes to http -func (h *HyperT) start(d *pb.Droplet) (bool, string) { +func (h *HyperT) start(d *virtpb.Droplet) (bool, string) { ready, result := me.cluster.DropletReady(d) if !ready { return false, result @@ -7,7 +7,7 @@ import ( "os" "strings" - "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/lib/virtigolib" "go.wit.com/log" ) @@ -41,8 +41,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) { } if route == "/create" { - var d *virtbuf.Droplet - d = new(virtbuf.Droplet) + var d *virtpb.Droplet + d = new(virtpb.Droplet) if err := d.Unmarshal(msg); err != nil { log.Info("proto.Unmarshal() failed on wire message len", len(msg)) log.Info("error =", err) diff --git a/importDomain.go b/importDomain.go index c7f7f45..b629bce 100644 --- a/importDomain.go +++ b/importDomain.go @@ -7,7 +7,7 @@ import ( "os" "time" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/lib/virtigolib" "go.wit.com/log" @@ -123,7 +123,7 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) { // this must be bool in string because accumulated output is sometimes // written to STDOUT, sometimes to http -func (h *HyperT) importDomain(d *pb.Droplet) (bool, string) { +func (h *HyperT) importDomain(d *virtpb.Droplet) (bool, string) { ready, result := me.cluster.DropletReady(d) if !ready { return false, result @@ -153,7 +153,7 @@ func (h *HyperT) importDomain(d *pb.Droplet) (bool, string) { return true, result } -func ExportLibvirtDomain(h *pb.Hypervisor, domainName string) (*libvirtxml.Domain, error) { +func ExportLibvirtDomain(h *virtpb.Hypervisor, domainName string) (*libvirtxml.Domain, error) { // attempt to get the domain record from virtigo xml, err := postImportDomain(h.Hostname, domainName) if err != nil { @@ -11,7 +11,7 @@ import ( "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/lib/virtigolib" "go.wit.com/log" ) @@ -40,7 +40,7 @@ func main() { // set defaults me.unstable = time.Now() // initialize the grid as unstable me.changed = false - me.hmap = make(map[*pb.Hypervisor]*HyperT) + me.hmap = make(map[*virtpb.Hypervisor]*HyperT) // how long a droplet can be missing until it's declared dead me.unstableTimeout = 17 * time.Second @@ -52,7 +52,7 @@ func main() { // how long the cluster must be stable before new droplets can be started me.clusterStableDuration = 37 * time.Second - me.cluster = pb.InitCluster() + me.cluster = virtpb.InitCluster() if err := me.cluster.ConfigLoad(); err != nil { log.Info("config load error", err) log.Info("") @@ -71,9 +71,9 @@ func main() { } fmt.Println("Droplet UUID:", d.Uuid) if d.Current == nil { - d.Current = new(pb.Current) + d.Current = new(virtpb.Current) } - d.SetState(pb.DropletState_OFF) + d.SetState(virtpb.DropletState_OFF) log.Info("droplet", d.Hostname) } hmm := "pihole.wit.com" @@ -84,7 +84,7 @@ func main() { log.Info("found droplet", d.Hostname, d) } - var newEvents []*pb.Event + var newEvents []*virtpb.Event // sanity check the cluster & droplets if _, _, err := ValidateDroplets(); err != nil { @@ -6,7 +6,7 @@ import ( "time" "go.wit.com/lib/gui/shell" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/log" "google.golang.org/protobuf/types/known/timestamppb" ) @@ -69,7 +69,7 @@ func (h *HyperT) pollHypervisor() { log.Log(POLL, start, "STATE:", state, "rest:", fields[2:]) // update the status to ON - d.SetState(pb.DropletState_ON) + d.SetState(virtpb.DropletState_ON) // set the LastPoll time to now now := time.Now() @@ -121,28 +121,28 @@ func (h *HyperT) pollHypervisor() { // should delete this from h.lastDroplets continue } - if d.Current.State == pb.DropletState_OFF { + if d.Current.State == virtpb.DropletState_OFF { log.Info(header, "droplet timed out and is off. remove from h.lastDroplets[] slice") delete(h.lastDroplets, name) continue } // everthing below here is dumb and needs to be rethought - if d.Current.State != pb.DropletState_UNKNOWN { - d.SetState(pb.DropletState_UNKNOWN) + if d.Current.State != virtpb.DropletState_UNKNOWN { + d.SetState(virtpb.DropletState_UNKNOWN) log.Info(header, "set state UNKNOWN here", name) } - if d.Current.State == pb.DropletState_UNKNOWN { + if d.Current.State == virtpb.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 := pb.FormatDuration(dur) + s := virtpb.FormatDuration(dur) log.Info(header, "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.SetState(pb.DropletState_OFF) + d.SetState(virtpb.DropletState_OFF) } } } @@ -158,7 +158,7 @@ func uptimeCheck() (bool, string) { var total int var working int var failed int - var missing []*pb.Droplet + var missing []*virtpb.Droplet var unknown int var unknownList []string @@ -166,7 +166,7 @@ func uptimeCheck() (bool, string) { for loop.Scan() { d := loop.Next() total += 1 - if d.StartState != pb.DropletState_ON { + if d.StartState != virtpb.DropletState_ON { continue } dur := time.Since(d.Current.LastPoll.AsTime()) // Calculate the elapsed time @@ -175,19 +175,19 @@ func uptimeCheck() (bool, string) { hname = d.Current.Hypervisor } switch d.Current.State { - case pb.DropletState_UNKNOWN: + case virtpb.DropletState_UNKNOWN: // log.Info("SKIP. hostname has not been polled yet", d.Hostname, d.hname) unknown += 1 unknownList = append(unknownList, d.Hostname) - case pb.DropletState_ON: + case virtpb.DropletState_ON: if dur > me.missingDropletTimeout { - log.Info("GOOD STATE MISSING", d.Hostname, hname, pb.FormatDuration(dur)) + log.Info("GOOD STATE MISSING", d.Hostname, hname, virtpb.FormatDuration(dur)) good = false - d.SetState(pb.DropletState_UNKNOWN) + d.SetState(virtpb.DropletState_UNKNOWN) failed += 1 continue } - l := pb.FormatDuration(dur) + l := virtpb.FormatDuration(dur) if l == "" { log.Info("DUR IS EMPTY", dur) missing = append(missing, d) @@ -195,13 +195,13 @@ 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, pb.FormatDuration(dur)) + case virtpb.DropletState_OFF: + log.Info("OFF STATE", d.StartState, d.Hostname, hname, virtpb.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, pb.FormatDuration(dur)) + log.Info("WTF STATE", d.StartState, d.Hostname, hname, "Current.State =", d.Current.State, virtpb.FormatDuration(dur)) good = false failed += 1 missing = append(missing, d) @@ -225,7 +225,7 @@ func uptimeCheck() (bool, string) { summary += "(killcount=" + fmt.Sprintf("%d", me.killcount) + ")" } last := time.Since(me.unstable) - s := strings.TrimSpace(pb.FormatDuration(last)) + s := strings.TrimSpace(virtpb.FormatDuration(last)) if last > me.clusterStableDuration { // the cluster has not been stable for 10 seconds summary += "(stable=" + s + ")" @@ -10,7 +10,7 @@ import ( "math/rand" "time" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/log" ) @@ -18,9 +18,9 @@ func isClusterStable() (string, error) { // how long has the cluster been stable? // wait until it is stable. use this to throttle droplet starts dur := time.Since(me.unstable) - good := fmt.Sprintln("trying to start droplet here. grid stable for: ", pb.FormatDuration(dur)) + good := fmt.Sprintln("trying to start droplet here. grid stable for: ", virtpb.FormatDuration(dur)) if dur < me.unstableTimeout { - tmp := pb.FormatDuration(me.unstableTimeout) + tmp := virtpb.FormatDuration(me.unstableTimeout) err := "grid is still too unstable (unstable timeout = " + tmp + ")\n" return good + err, errors.New(err) } @@ -52,7 +52,7 @@ func Start(name string) (string, error) { } // is the droplet already on? - if d.Current.State == pb.DropletState_ON { + if d.Current.State == virtpb.DropletState_ON { result = "EVENT start droplet " + d.Hostname + " is already ON" return result, errors.New(result) } @@ -4,7 +4,7 @@ import ( "time" "go.wit.com/gui" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" ) var me virtigoT @@ -21,24 +21,24 @@ func (b *virtigoT) Enable() { // this app's variables type virtigoT struct { - cluster *pb.Cluster // basic cluster settings - myGui *gui.Node // the gui toolkit handle - e *pb.Events // virtbuf events - hmap map[*pb.Hypervisor]*HyperT // map to the local struct - names []string // ? - hypers []*HyperT // notsure - killcount int // how many times virtigo-d has had to been killed - unstable time.Time // the last time the cluster was incorrect - changed bool // have things changed? - hyperPollDelay time.Duration // how often to poll the hypervisors - unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead - clusterStableDuration time.Duration // how long the cluster must be stable before new droplets can be started - missingDropletTimeout time.Duration // how long a droplet can be missing for + cluster *virtpb.Cluster // basic cluster settings + myGui *gui.Node // the gui toolkit handle + e *virtpb.Events // virt protobuf events + hmap map[*virtpb.Hypervisor]*HyperT // map to the local struct + names []string // ? + hypers []*HyperT // notsure + killcount int // how many times virtigo-d has had to been killed + unstable time.Time // the last time the cluster was incorrect + changed bool // have things changed? + hyperPollDelay time.Duration // how often to poll the hypervisors + unstableTimeout time.Duration // how long a droplet can be unstable until it's declared dead + clusterStableDuration time.Duration // how long the cluster must be stable before new droplets can be started + missingDropletTimeout time.Duration // how long a droplet can be missing for } // the stuff that is needed for a hypervisor type HyperT struct { - pb *pb.Hypervisor // the Hypervisor protobuf + pb *virtpb.Hypervisor // the Hypervisor protobuf dog *time.Ticker // the watchdog timer itself lastpoll time.Time // the last time the hypervisor polled lastDroplets map[string]time.Time // the vm's in the last poll diff --git a/validate.go b/validate.go index 284bde3..e648813 100644 --- a/validate.go +++ b/validate.go @@ -22,7 +22,7 @@ import ( "github.com/google/uuid" - pb "go.wit.com/lib/protobuf/virtbuf" + "go.wit.com/lib/protobuf/virtpb" "go.wit.com/log" ) @@ -42,9 +42,9 @@ func ValidateUniqueMac(mac string) bool { } // records all the known paths. this should go in the protobuf -func addClusterFilepath(dir string) *pb.Event { +func addClusterFilepath(dir string) *virtpb.Event { var found bool = false - var e *pb.Event + var e *virtpb.Event for _, d := range me.cluster.Dirs { if d == dir { // found dir @@ -55,7 +55,7 @@ func addClusterFilepath(dir string) *pb.Event { if !found { if dir != "." { // make a new Add Event - e = pb.NewAddEvent(nil, "Add Cluster Directory", dir) + e = virtpb.NewAddEvent(nil, "Add Cluster Directory", dir) me.cluster.Dirs = append(me.cluster.Dirs, dir) } } @@ -63,7 +63,7 @@ func addClusterFilepath(dir string) *pb.Event { } // returns the droplet using a filename -func lookupFilename(filename string) *pb.Droplet { +func lookupFilename(filename string) *virtpb.Droplet { filebase := filepath.Base(filename) loop := me.cluster.DropletsAll() // get the list of droplets @@ -110,8 +110,8 @@ func ValidateUniqueFilenames() bool { return ok } -func ValidateDiskFilenames() ([]*pb.Event, error) { - var alle []*pb.Event +func ValidateDiskFilenames() ([]*virtpb.Event, error) { + var alle []*virtpb.Event loop := me.cluster.DropletsAll() // get the list of droplets for loop.Scan() { @@ -225,11 +225,11 @@ func ValidateDroplets() (map[string]string, map[string]string, error) { log.Info("duplicate UUID", d.Uuid, umap[d.Uuid]) log.Info("duplicate UUID", d.Uuid, d.Hostname) if d.Archive == nil { - d.Archive = new(pb.Archive) + d.Archive = new(virtpb.Archive) log.Info("d.Archive was nil for", d.Hostname) // os.Exit(-1) } - d.Archive.Reason = pb.DropletArchive_DUP + d.Archive.Reason = virtpb.DropletArchive_DUP continue // return umap, macs, errors.New("duplicate UUID: " + d.Uuid) } @@ -259,7 +259,7 @@ func searchForDuplicateUUIDs() { /* // remove from the slice func deleteDroplet(bad int) { - var all *pb.Droplets + var all *virtpb.Droplets all = me.cluster.DeleteDroplet(b *db.Droplet) fmt.Println("deleting", bad, all.Droplets[bad].Hostname) @@ -278,7 +278,7 @@ func deleteDroplet(bad int) { // check qemu domain id // check spice and vnc ports // check filenames -func ValidateDroplet(check *pb.Droplet) error { +func ValidateDroplet(check *virtpb.Droplet) error { // check for duplicate uuid's loop := me.cluster.DropletsAll() // get the list of droplets for loop.Scan() { @@ -290,12 +290,12 @@ func ValidateDroplet(check *pb.Droplet) error { // UUID already exists log.Info("duplicate UUID", d.Uuid, d.Hostname) log.Info("duplicate UUID", d.Uuid, check.Hostname) - // d.Archive = new(pb.DropletArchive) + // d.Archive = new(virtpb.DropletArchive) if d.Archive == nil { log.Info("d.Archive == nil") os.Exit(-1) } - d.Archive.Reason = pb.DropletArchive_DUP + d.Archive.Reason = virtpb.DropletArchive_DUP // return errors.New("duplicate UUID: " + d.Uuid) } } @@ -333,9 +333,9 @@ func ValidateDroplet(check *pb.Droplet) error { return nil } -func setUniqueSpicePort(check *pb.Droplet) error { - var ports map[int64]*pb.Droplet - ports = make(map[int64]*pb.Droplet) +func setUniqueSpicePort(check *virtpb.Droplet) error { + var ports map[int64]*virtpb.Droplet + ports = make(map[int64]*virtpb.Droplet) // check spice ports // checkn.SpicePort = getUniqueSpicePort() @@ -348,13 +348,13 @@ func setUniqueSpicePort(check *pb.Droplet) error { if dup, ok := ports[d.SpicePort]; ok { // dup := ports[d.SpicePort] log.Warn("duplicate ports", d.SpicePort, d.Hostname, d.Current.State) - if d.Current.State != pb.DropletState_ON { + if d.Current.State != virtpb.DropletState_ON { // hack for now. should be safe to erase this d.SpicePort = 0 log.Warn("erasing port for non-ON droplet", d.SpicePort, d.Hostname, d.Current.State) } log.Warn("duplicate ports", dup.SpicePort, dup.Hostname, dup.Current.State) - if dup.Current.State != pb.DropletState_ON { + if dup.Current.State != virtpb.DropletState_ON { // hack for now. should be safe to erase this dup.SpicePort = 0 log.Warn("erasing port for non-ON droplet", dup.SpicePort, dup.Hostname, dup.Current.State) |
