Skip to content

Commit

Permalink
Merge pull request #128 from m-lab/preserve-errors
Browse files Browse the repository at this point in the history
Preserve error states
  • Loading branch information
gfr10598 authored Feb 6, 2019
2 parents ee0ef0a + 6f65257 commit 90573e6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions reproc/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func NewTaskHandler(exec state.Executor, queues []string, saver state.Saver) *Ta
var ErrTerminating = errors.New("TaskHandler is terminating")

// StartTask starts a single task. It should be properly initialized except for saver.
// If the task had previously errored, this should clear the error from datastore.
func (th *TaskHandler) StartTask(ctx context.Context, t state.Task) {
t.SetSaver(th.saver)

Expand Down
7 changes: 4 additions & 3 deletions rex/rex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,10 @@ func TestWithTaskQueue(t *testing.T) {
if counter.Count() != 9 {
t.Error("Wrong number of client calls", counter.Count())
}
if len(saver.GetDeletes()) != 3 {
t.Error("Wrong number of task deletes", len(saver.GetDeletes()))
}

// TODO: The tasks currently end in error, so there are no task
// deletes. If we change this behavior, we might want to check the
// value of saver.Deletes() here.

tasks := saver.GetTasks()
for _, task := range tasks {
Expand Down
9 changes: 7 additions & 2 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,13 @@ loop:
}
}
}
metrics.CompletedCount.WithLabelValues("todo - add exp type").Inc()
t.Delete(ctx)
if t.ErrMsg == "" {
// Only delete the state entry if it completed without error.
t.Delete(ctx)
metrics.CompletedCount.WithLabelValues("todo - add exp type").Inc()
} else {
metrics.CompletedCount.WithLabelValues(StateNames[t.State] + " Error").Inc()
}
term.Done()
}

Expand Down

0 comments on commit 90573e6

Please sign in to comment.