global hypervisor poll delay

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-22 19:57:49 -05:00
parent 5b99a88e06
commit a3ea303ab8
4 changed files with 8 additions and 6 deletions

View File

@ -36,7 +36,6 @@ func readConfigFile() {
h = new(HyperT) h = new(HyperT)
h.pb = pbh h.pb = pbh
h.Delay = 5 * time.Second
h.lastpoll = time.Now() h.lastpoll = time.Now()
me.hypers = append(me.hypers, h) me.hypers = append(me.hypers, h)

View File

@ -35,6 +35,9 @@ func main() {
// initialize the grid as unstable // initialize the grid as unstable
me.unstable = time.Now() me.unstable = time.Now()
// how often to poll the hypervisors
me.delay = 5 * time.Second
/* /*
log.Info("command line hypervisors:", argv.Hosts) log.Info("command line hypervisors:", argv.Hosts)
for _, name := range argv.Hosts { for _, name := range argv.Hosts {

View File

@ -24,6 +24,7 @@ type virtigoT struct {
names []string names []string
hypers []*HyperT hypers []*HyperT
droplets []*DropletT droplets []*DropletT
delay time.Duration // how often to poll the hypervisors
killcount int killcount int
unstable time.Time // the last time the cluster was incorrect unstable time.Time // the last time the cluster was incorrect
} }
@ -31,8 +32,7 @@ type virtigoT struct {
// the stuff that is needed for a hypervisor // the stuff that is needed for a hypervisor
type HyperT struct { type HyperT struct {
pb *pb.Hypervisor // the Hypervisor protobuf pb *pb.Hypervisor // the Hypervisor protobuf
Delay time.Duration // how often to poll the hypervisor dog *time.Ticker // the watchdog timer itself
Dog *time.Ticker // the watchdog timer itself
lastpoll time.Time // the last time the hypervisor polled lastpoll time.Time // the last time the hypervisor polled
killcount int killcount int
} }

View File

@ -15,8 +15,8 @@ func TimeFunction(f func()) time.Duration {
} }
func (h *HyperT) NewWatchdog() { func (h *HyperT) NewWatchdog() {
h.Dog = time.NewTicker(h.Delay) h.dog = time.NewTicker(me.delay)
defer h.Dog.Stop() defer h.dog.Stop()
done := make(chan bool) done := make(chan bool)
/* /*
// this example would exit/destroy the ticker in 10 seconds // this example would exit/destroy the ticker in 10 seconds
@ -30,7 +30,7 @@ func (h *HyperT) NewWatchdog() {
case <-done: case <-done:
fmt.Println("Done!") fmt.Println("Done!")
return return
case t := <-h.Dog.C: case t := <-h.dog.C:
log.Log(POLL, "Watchdog() ticked", h.pb.Hostname, "Current time: ", t) log.Log(POLL, "Watchdog() ticked", h.pb.Hostname, "Current time: ", t)
h.pollHypervisor() h.pollHypervisor()
// h.Scan() // h.Scan()