Skip to content

Commit

Permalink
remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
chelseakomlo committed Mar 15, 2018
1 parent 6dd47cb commit 244389c
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 86 deletions.
69 changes: 2 additions & 67 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 0 additions & 6 deletions client/fingerprint_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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,
Expand Down
13 changes: 0 additions & 13 deletions client/fingerprint_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func TestFingerprintManager_Run_MockDriver(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testLogger(),
)
Expand Down Expand Up @@ -71,7 +70,6 @@ func TestFingerprintManager_Run_ResourcesFingerprint(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -108,7 +106,6 @@ func TestFingerprintManager_Fingerprint_Run(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -150,7 +147,6 @@ func TestFingerprintManager_Fingerprint_Periodic(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -222,7 +218,6 @@ func TestFingerprintManager_HealthCheck_Driver(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -324,7 +319,6 @@ func TestFingerprintManager_HealthCheck_Periodic(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -429,7 +423,6 @@ func TestFimgerprintManager_Run_InWhitelist(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -468,7 +461,6 @@ func TestFingerprintManager_Run_InBlacklist(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -508,7 +500,6 @@ func TestFingerprintManager_Run_Combination(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -550,7 +541,6 @@ func TestFingerprintManager_Run_WhitelistDrivers(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -587,7 +577,6 @@ func TestFingerprintManager_Run_AllDriversBlacklisted(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -629,7 +618,6 @@ func TestFingerprintManager_Run_DriversWhiteListBlacklistCombination(t *testing.
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down Expand Up @@ -673,7 +661,6 @@ func TestFingerprintManager_Run_DriversInBlacklist(t *testing.T) {
testClient.config.Node,
testClient.shutdownCh,
testClient.updateNodeFromFingerprint,
testClient.updateNodeFromHealthCheck,
testClient.updateNodeFromDriver,
testClient.logger,
)
Expand Down

0 comments on commit 244389c

Please sign in to comment.