Skip to content

Commit

Permalink
notes from walk through
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar authored and chelseakomlo committed Mar 21, 2018
1 parent 8a0ed4e commit 3ad03d9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,14 @@ func (c *Client) updateNodeFromFingerprint(response *cstructs.FingerprintRespons
c.config.Node.Resources.Merge(response.Resources)
}

// XXX --------------
// All drivers only expose DriverInfo
// This becomes a separate setter. So we have:
// * updateNodeFromFingerprinters
// * updateNodeFromDriver(fingerprint, health *DriverInfo)
/// TODO is anything updating the Node.Attributes based on updating
// driverinfos

for name, newVal := range response.Drivers {
oldVal := c.config.Node.Drivers[name]
if oldVal == nil && newVal != nil {
Expand All @@ -1021,6 +1029,35 @@ func (c *Client) updateNodeFromFingerprint(response *cstructs.FingerprintRespons
return c.config.Node
}

/* Model for converging the periodic fingerprinting and health checking:
func watcher(driver Driver) {
p := driver.Periodic()
healthChecker driver.HealthChecker()
hDur := healthChecker.Periodic()
var t1, t2 time.Timer
if healthChecker {
t2 = time.NewTimer(hDur)
}
for {
select {
case shutdown:
case periodicFingerprint <- t1.C:
// Do stuff
t1.Reset(its duration)
case healthCheck <- t2.C: // Nil: never fire
// Do stuff
newHealth := driver.HealthCheck()
updateNodeFromDriver(nil, newHealth)
t2.Reset(its duration)
}
}
}
*/

// updateNodeFromHealthCheck receives a health check response and updates the
// node accordingly
func (c *Client) updateNodeFromHealthCheck(response *cstructs.HealthCheckResponse) *structs.Node {
Expand Down
2 changes: 2 additions & 0 deletions client/fingerprint_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (fm *FingerprintManager) runFingerprint(f fingerprint.Fingerprint, period t
}
}

// XXX Do we need this for now
// runHealthCheck runs each health check individually on an ongoing basis
func (fm *FingerprintManager) runHealthCheck(hc fingerprint.HealthCheck, period time.Duration, name string) {
fm.logger.Printf("[DEBUG] client.fingerprint_manager: healthchecking %s every %v", name, period)
Expand Down Expand Up @@ -294,6 +295,7 @@ func (fm *FingerprintManager) setupFingerprinters(fingerprints []string) error {
go fm.runFingerprint(f, period, name)
}

// XXX This code path doesn't exist right now
if hc, ok := f.(fingerprint.HealthCheck); ok {
req := &cstructs.HealthCheckIntervalRequest{}
var resp cstructs.HealthCheckIntervalResponse
Expand Down

0 comments on commit 3ad03d9

Please sign in to comment.