From 334f5fb82689a70d274ba42fd66fee76d044d027 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Thu, 19 Apr 2018 12:59:16 -0500 Subject: [PATCH] better comments and remove commented code --- nomad/deploymentwatcher/deployment_watcher.go | 4 ++++ nomad/deploymentwatcher/deployments_watcher_test.go | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/nomad/deploymentwatcher/deployment_watcher.go b/nomad/deploymentwatcher/deployment_watcher.go index 22b8a4b5e..c27f2eab6 100644 --- a/nomad/deploymentwatcher/deployment_watcher.go +++ b/nomad/deploymentwatcher/deployment_watcher.go @@ -406,6 +406,10 @@ FAIL: if !next.Equal(currentDeadline) { prevDeadlineZero := currentDeadline.IsZero() currentDeadline = next + // The most recent deadline can be zero if no allocs were created for this deployment. + // The deadline timer would have already been stopped once in that case. To prevent + // deadlocking on the already stopped deadline timer, we only drain the channel if + // the previous deadline was not zero. if !prevDeadlineZero && !deadlineTimer.Stop() { <-deadlineTimer.C } diff --git a/nomad/deploymentwatcher/deployments_watcher_test.go b/nomad/deploymentwatcher/deployments_watcher_test.go index 168f04612..437a59590 100644 --- a/nomad/deploymentwatcher/deployments_watcher_test.go +++ b/nomad/deploymentwatcher/deployments_watcher_test.go @@ -899,10 +899,7 @@ func TestDeploymentWatcher_Watch_StartWithoutProgressDeadline(t *testing.T) { a := mock.Alloc() a.CreateTime = time.Now().UnixNano() a.DeploymentID = d.ID - /*a.DeploymentStatus = &structs.AllocDeploymentStatus{ - Healthy: helper.BoolToPtr(false), - Timestamp: time.Now(), - }*/ + assert.Nil(m.state.UpsertAllocs(m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") d.TaskGroups["web"].ProgressDeadline = 500 * time.Millisecond