From b9ea2765ecb0372037b1dff24f1ad89c8a75950f Mon Sep 17 00:00:00 2001 From: Michael Schurter Date: Wed, 19 Apr 2017 13:05:41 -0700 Subject: [PATCH] Thanks go vet! --- client/consul_test.go | 2 +- command/agent/consul/script.go | 1 + command/agent/consul/script_test.go | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/consul_test.go b/client/consul_test.go index 7d68faae2..4c34fd9a3 100644 --- a/client/consul_test.go +++ b/client/consul_test.go @@ -55,7 +55,7 @@ func newMockConsulServiceClient() *mockConsulServiceClient { func (m *mockConsulServiceClient) UpdateTask(allocID string, old, new *structs.Task, exec driver.ScriptExecutor) error { m.mu.Lock() defer m.mu.Unlock() - m.logger.Printf("[TEST] mock_consul: UpdateTask(%q, %q, %q, %T)", allocID, old, new, exec) + m.logger.Printf("[TEST] mock_consul: UpdateTask(%q, %v, %v, %T)", allocID, old, new, exec) m.ops = append(m.ops, newMockConsulOp("update", allocID, old, exec)) return nil } diff --git a/command/agent/consul/script.go b/command/agent/consul/script.go index 9f540d7fa..379025f76 100644 --- a/command/agent/consul/script.go +++ b/command/agent/consul/script.go @@ -96,6 +96,7 @@ func (s *scriptCheck) run() *scriptHandle { switch execctx.Err() { case context.Canceled: // check removed during execution; exit + cancel() return case context.DeadlineExceeded: metrics.IncrCounter([]string{"client", "consul", "script_timeouts"}, 1) diff --git a/command/agent/consul/script_test.go b/command/agent/consul/script_test.go index 35902c9f8..53aed1f8d 100644 --- a/command/agent/consul/script_test.go +++ b/command/agent/consul/script_test.go @@ -119,7 +119,7 @@ func TestConsulScript_Exec_Timeout(t *testing.T) { select { case update := <-hb.updates: if update.status != api.HealthCritical { - t.Error("expected %q due to timeout but received %q", api.HealthCritical, update) + t.Errorf("expected %q due to timeout but received %q", api.HealthCritical, update) } case <-time.After(3 * time.Second): t.Fatalf("timed out waiting for script check to exit") @@ -167,7 +167,7 @@ func TestConsulScript_Exec_TimeoutCritical(t *testing.T) { select { case update := <-hb.updates: if update.status != api.HealthCritical { - t.Error("expected %q due to timeout but received %q", api.HealthCritical, update) + t.Errorf("expected %q due to timeout but received %q", api.HealthCritical, update) } if update.output != context.DeadlineExceeded.Error() { t.Errorf("expected output=%q but found: %q", context.DeadlineExceeded.Error(), update.output) @@ -214,7 +214,7 @@ func TestConsulScript_Exec_Shutdown(t *testing.T) { select { case update := <-hb.updates: if update.status != api.HealthPassing { - t.Error("expected %q due to timeout but received %q", api.HealthCritical, update) + t.Errorf("expected %q due to timeout but received %q", api.HealthCritical, update) } case <-time.After(3 * time.Second): t.Fatalf("timed out waiting for script check to exit")