Skip to content

Commit

Permalink
Incrementing the start counter when we are actually starting a container
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Nov 1, 2017
1 parent 2fdedc4 commit 2a97a9b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions client/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,6 @@ func (r *AllocRunner) setTaskState(taskName, state string, event *structs.TaskEv
case structs.TaskStateDead:
// Capture the finished time. If it has never started there is no finish
// time
metrics.IncrCounter([]string{"client", "allocs", r.alloc.Job.Name, r.alloc.TaskGroup, taskName, "dead"}, 1)
if !taskState.StartedAt.IsZero() {
taskState.FinishedAt = time.Now().UTC()
}
Expand Down Expand Up @@ -754,9 +753,6 @@ func (r *AllocRunner) Run() {
defer close(r.waitCh)
go r.dirtySyncState()

// Increment alloc runner start counter. Incr'd even when restoring existing tasks so 1 start != 1 task execution
metrics.IncrCounter([]string{"client", "allocs", r.alloc.Job.Name, r.alloc.TaskGroup, "start"}, 1)

// Find the task group to run in the allocation
alloc := r.Alloc()
tg := alloc.Job.LookupTaskGroup(alloc.TaskGroup)
Expand Down Expand Up @@ -811,6 +807,9 @@ func (r *AllocRunner) Run() {
return
}

// Increment alloc runner start counter. Incr'd even when restoring existing tasks so 1 start != 1 task execution
metrics.IncrCounter([]string{"client", "allocs", r.alloc.Job.Name, r.alloc.TaskGroup, "start"}, 1)

// Start the watcher
wCtx, watcherCancel := context.WithCancel(r.ctx)
go r.watchHealth(wCtx)
Expand Down

0 comments on commit 2a97a9b

Please sign in to comment.