Commit 516b3d56 authored by Chelsea Holland Komlo's avatar Chelsea Holland Komlo
Browse files

fix up codereview feedback

parent 05782713
Branches unavailable
No related merge requests found
Showing with 18 additions and 12 deletions
+18 -12
......@@ -551,7 +551,7 @@ func (d *DockerDriver) Fingerprint(req *cstructs.FingerprintRequest, resp *cstru
return nil
}
// HealthChck implements the interface for the HealthCheck interface. This
// HealthCheck implements the interface for the HealthCheck interface. This
// performs a health check on the docker driver, asserting whether the docker
// driver is responsive to a `docker ps` command.
func (d *DockerDriver) HealthCheck(req *cstructs.HealthCheckRequest, resp *cstructs.HealthCheckResponse) error {
......@@ -562,14 +562,14 @@ func (d *DockerDriver) HealthCheck(req *cstructs.HealthCheckRequest, resp *cstru
client, _, err := d.dockerClients()
if err != nil {
d.logger.Printf("[WARN] driver.docker: docker driver is available but is unresponsive to `docker ps`")
d.logger.Printf("[WARN] driver.docker: failed to retrieve Docker client in the process of a docker health check: %v", err)
resp.AddDriverInfo("docker", unhealthy)
return err
}
_, err = client.ListContainers(docker.ListContainersOptions{All: false})
if err != nil {
d.logger.Printf("[WARN] driver.docker: docker driver is available but is unresponsive to `docker ps`")
d.logger.Printf("[WARN] driver.docker: failed to list Docker containers in the process of a docker health check: %v", err)
resp.AddDriverInfo("docker", unhealthy)
return err
}
......
......@@ -2,6 +2,7 @@ package client
import (
"log"
"strings"
"sync"
"time"
......@@ -24,7 +25,7 @@ type FingerprintManager struct {
// associated node
updateNodeAttributes func(*cstructs.FingerprintResponse) *structs.Node
// UpdateHealthCheck is a callback to the client to update the state of the
// 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
logger *log.Logger
......@@ -76,7 +77,7 @@ func (fm *FingerprintManager) runHealthCheck(hc fingerprint.HealthCheck, period
case <-time.After(period):
err := fm.healthCheck(name, hc)
if err != nil {
fm.logger.Printf("[DEBUG] client.fingerprint_manager: health checking for %v failed: %+v", name, err)
fm.logger.Printf("[DEBUG] client.fingerprint_manager: health checking for %v failed: %v", name, err)
continue
}
......@@ -151,8 +152,14 @@ func (fm *FingerprintManager) fingerprintDriver(name string, f fingerprint.Finge
// support this. Doing this so that we can enable this iteratively and also
// in a backwards compatible way, where node attributes for drivers will
// eventually be phased out.
strippedAttributes := make(map[string]string, 0)
for k, v := range response.Attributes {
copy := k
strings.Replace(copy, "driver.", "", 1)
strippedAttributes[k] = v
}
di := &structs.DriverInfo{
Attributes: response.Attributes,
Attributes: strippedAttributes,
Detected: response.Detected,
}
response.AddDriver(name, di)
......
package structs
import (
"strings"
"time"
)
......@@ -42,7 +41,7 @@ func (di *DriverInfo) HealthCheckEquals(other *DriverInfo) bool {
return false
}
if strings.Compare(di.HealthDescription, other.HealthDescription) != 0 {
if di.HealthDescription == other.HealthDescription {
return false
}
......
......@@ -130,10 +130,10 @@ func (c *DriverChecker) hasDrivers(option *structs.Node) bool {
for driver := range c.drivers {
driverStr := fmt.Sprintf("driver.%s", driver)
// TODO this is a compatibility mechanism- as of Nomad 0.8, nodes have a
// DriverInfo that corresponds with every driver. As a Nomad server might
// be on a later version than a Nomad client, we need to check for
// compatibility here to verify the client supports this.
// COMPAT: Remove in 0.X: As of Nomad 0.8, nodes have a DriverInfo that
// corresponds with every driver. As a Nomad server might be on a later
// version than a Nomad client, we need to check for compatibility here
// to verify the client supports this.
if option.Drivers != nil {
driverInfo := option.Drivers[driver]
if driverInfo == nil {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment