diff --git a/client/client.go b/client/client.go index 2d303ad3f4f..7be6298ece5 100644 --- a/client/client.go +++ b/client/client.go @@ -259,8 +259,8 @@ func NewClient(cfg *config.Config, consulCatalog consul.CatalogAPI, consulServic } fingerprintManager := NewFingerprintManager(c.GetConfig, c.config.Node, - c.shutdownCh, c.updateNodeFromFingerprint, c.updateNodeFromHealthCheck, - c.updateNodeFromDriver, c.logger) + c.shutdownCh, c.updateNodeFromFingerprint, c.updateNodeFromDriver, + c.logger) // Fingerprint the node and scan for drivers if err := fingerprintManager.Run(); err != nil { @@ -1086,71 +1086,6 @@ func (c *Client) updateNodeFromDriver(name string, fingerprint, health *structs. 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 -// TODO is this even needed? -func (c *Client) updateNodeFromHealthCheck(response *cstructs.HealthCheckResponse) *structs.Node { - c.configLock.Lock() - defer c.configLock.Unlock() - - nodeHasChanged := false - - // update the node with the latest driver health information - for name, newVal := range response.Drivers { - if newVal == nil { - continue - } - oldVal := c.config.Node.Drivers[name] - if newVal.HealthCheckEquals(oldVal) { - - // make sure we accurately reflect the last time a health check has been - // performed for the driver. - oldVal.UpdateTime = newVal.UpdateTime - continue - } - nodeHasChanged = true - if oldVal == nil { - c.config.Node.Drivers[name] = newVal - } else { - } - } - - if nodeHasChanged { - c.updateNode() - } - - return c.config.Node -} - // resourcesAreEqual is a temporary function to compare whether resources are // equal. We can use this until we change fingerprinters to set pointers on a // return type. diff --git a/client/fingerprint_manager.go b/client/fingerprint_manager.go index 5f1207a5214..d3fccb265f8 100644 --- a/client/fingerprint_manager.go +++ b/client/fingerprint_manager.go @@ -25,10 +25,6 @@ type FingerprintManager struct { // associated node updateNodeAttributes func(*cstructs.FingerprintResponse) *structs.Node - // updateHealthCheck is a callback to the client to update the state of the - // node for resources that require a health check - updateHealthCheck func(*cstructs.HealthCheckResponse) *structs.Node - updateNodeFromDriver func(string, *structs.DriverInfo, *structs.DriverInfo) *structs.Node logger *log.Logger } @@ -39,13 +35,11 @@ func NewFingerprintManager(getConfig func() *config.Config, node *structs.Node, shutdownCh chan struct{}, updateNodeAttributes func(*cstructs.FingerprintResponse) *structs.Node, - updateHealthCheck func(*cstructs.HealthCheckResponse) *structs.Node, updateNodeFromDriver func(string, *structs.DriverInfo, *structs.DriverInfo) *structs.Node, logger *log.Logger) *FingerprintManager { return &FingerprintManager{ getConfig: getConfig, updateNodeAttributes: updateNodeAttributes, - updateHealthCheck: updateHealthCheck, updateNodeFromDriver: updateNodeFromDriver, node: node, shutdownCh: shutdownCh, diff --git a/client/fingerprint_manager_test.go b/client/fingerprint_manager_test.go index f7008cd7193..82cb2186f8c 100644 --- a/client/fingerprint_manager_test.go +++ b/client/fingerprint_manager_test.go @@ -35,7 +35,6 @@ func TestFingerprintManager_Run_MockDriver(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testLogger(), ) @@ -71,7 +70,6 @@ func TestFingerprintManager_Run_ResourcesFingerprint(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -108,7 +106,6 @@ func TestFingerprintManager_Fingerprint_Run(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -150,7 +147,6 @@ func TestFingerprintManager_Fingerprint_Periodic(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -222,7 +218,6 @@ func TestFingerprintManager_HealthCheck_Driver(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -324,7 +319,6 @@ func TestFingerprintManager_HealthCheck_Periodic(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -429,7 +423,6 @@ func TestFimgerprintManager_Run_InWhitelist(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -468,7 +461,6 @@ func TestFingerprintManager_Run_InBlacklist(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -508,7 +500,6 @@ func TestFingerprintManager_Run_Combination(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -550,7 +541,6 @@ func TestFingerprintManager_Run_WhitelistDrivers(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -587,7 +577,6 @@ func TestFingerprintManager_Run_AllDriversBlacklisted(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -629,7 +618,6 @@ func TestFingerprintManager_Run_DriversWhiteListBlacklistCombination(t *testing. testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, ) @@ -673,7 +661,6 @@ func TestFingerprintManager_Run_DriversInBlacklist(t *testing.T) { testClient.config.Node, testClient.shutdownCh, testClient.updateNodeFromFingerprint, - testClient.updateNodeFromHealthCheck, testClient.updateNodeFromDriver, testClient.logger, )