Compare commits

...

2 Commits

Author SHA1 Message Date
Jeff Carr e6fb7352ae quiet debugging 2025-04-23 02:43:18 -05:00
Jeff Carr c9ef4f0b82 make an EDIT event 2025-04-22 20:50:00 -05:00
4 changed files with 24 additions and 16 deletions

16
add.go
View File

@ -62,13 +62,15 @@ func (c *OldCluster) FindDropletByName(name string) *Droplet {
}
func (c *OldCluster) FindDropletByUuid(id string) *Droplet {
log.Info("START FIND", id)
loop := c.d.All() // get the list of droplets
for loop.Scan() {
d := loop.Next()
log.Info("droplet:", d.Hostname, d.Uuid)
}
log.Info("END FIND", id)
/*
log.Info("START FIND", id)
loop := c.d.All() // get the list of droplets
for loop.Scan() {
d := loop.Next()
log.Info("droplet:", d.Hostname, d.Uuid)
}
log.Info("END FIND", id)
*/
return c.d.FindByUuid(id)
}

View File

@ -73,7 +73,7 @@ func (d *Droplet) NewChangeEvent(fname string, origval any, newval any) *Event {
var e *Event
e = new(Event)
e.Droplet = d.Hostname
e.DropletName = d.Hostname
e.OrigVal = convertToString(origval)
e.NewVal = convertToString(newval)
e.FieldName = fname
@ -99,12 +99,12 @@ func NewAddEvent(a any, fname string, newval any) *Event {
case *Droplet:
var d *Droplet
d = a.(*Droplet)
e.Droplet = d.Hostname
e.DropletName = d.Hostname
case nil:
e.Droplet = "<nil>"
e.DropletName = "<nil>"
default:
log.Info("newAddEvent() unknown type", v)
e.Droplet = "on something somewhere"
e.DropletName = "on something somewhere"
}
e.NewVal = convertToString(newval)
@ -177,7 +177,7 @@ func (c *OldCluster) ChangeDropletState(d *Droplet, newState DropletState) error
var e *Event
e = new(Event)
e.Droplet = d.Hostname
e.DropletName = d.Hostname
e.OrigVal = convertToString(d.Current.State)
e.NewVal = convertToString(newState)
e.FieldName = "status"
@ -209,7 +209,7 @@ func (c *OldCluster) DropletMoved(d *Droplet, newh *Hypervisor) error {
var e *Event
e = new(Event)
e.Droplet = d.Hostname
e.DropletName = d.Hostname
e.OrigVal = d.Current.Hypervisor
e.NewVal = newh.Hostname
e.FieldName = "droplet migrate"

View File

@ -99,7 +99,7 @@ func (c *OldCluster) ConfigLoad() error {
return err
}
} else {
fmt.Println("ERROR HERE IN Hypervisors")
log.Warn("ERROR HERE IN Hypervisors")
return err
}
@ -108,8 +108,11 @@ func (c *OldCluster) ConfigLoad() error {
// does it not stay allocated after this function ends?
c.e = new(Events)
}
if err := c.e.loadEvents(); err != nil {
return err
// ignore events.pb since these should be sent elsewhere
log.Warn("Events failed to load, ignoring:", err)
return nil
}
return nil
}

View File

@ -3,6 +3,7 @@ package virtpb;
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
import "google/protobuf/any.proto"; // Import the well-known type for Timestamp
import "droplet.proto";
// global settings for autogenpb `autogenpb:no-sort` `autogenpb:mutex`
@ -26,7 +27,7 @@ message Event { // `autogenpb:marsh
}
int32 id = 1; // `autogenpb:unique` // should be unique across the cluster
EventType etype = 2;
string droplet = 3; // name of the droplet
string dropletName = 3; // name of the droplet
string dropletUuid = 4; // uuid of the droplet
string hypervisor = 5; // name of the hypervisor
string hypervisorUuid = 6; // uuid of the hypervisor
@ -39,6 +40,7 @@ message Event { // `autogenpb:marsh
google.protobuf.Any newAny = 13; // anypb format
string error = 14; // what went wrong
status state = 15; // state of the event
Droplet droplet = 16; // droplet
}
enum EventType {
ADD = 0;
@ -54,4 +56,5 @@ enum EventType {
FAIL = 10; // everything failed
CRASH = 11; // droplet hard crashed
CHANGE = 12; // droplet or hypervisor config change
EDIT = 13; // edit droplet settings
}