Skip to content

Commit

Permalink
fix(taskrunner): consistent, nicer formatting for task failed log (#391)
Browse files Browse the repository at this point in the history
This changes this log:

```
2024-03-21T06:37:37.224Z [pebble] [change 32 "Start service \"svc1\"" task] failed: cannot start service: exited quickly with code 1
```

To this, which is more consistent with the formatting of the other
Pebble logs:

```
2024-03-21T06:43:09.559Z [pebble] Change 33 task (Start service "svc1") failed: cannot start service: exited quickly with code 1
```

This log was introduced in this commit:

e494ff2#diff-e8b7c8da8654dde95838cfa0cc4b497cdd32050ea3a1bf0640e6404303aef0d6R294
which was pulled across from snapd, which originally added it here:
canonical/snapd@8b2a5a8
  • Loading branch information
benhoyt authored Mar 27, 2024
1 parent fc1f14b commit 0d00024
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internals/overlord/state/taskrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (r *TaskRunner) run(t *Task) {
t.SetStatus(ErrorStatus)
t.Errorf("%s", err)
// ensure the error is available in the global log too
logger.Noticef("[change %s %q task] failed: %v", t.Change().ID(), t.Summary(), err)
logger.Noticef("Change %s task (%s) failed: %v", t.Change().ID(), t.Summary(), err)
if r.taskErrorCallback != nil {
r.taskErrorCallback(err)
}
Expand Down
2 changes: 1 addition & 1 deletion internals/overlord/state/taskrunner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ func (ts *taskRunnerSuite) TestErrorCallbackCalledOnError(c *C) {
c.Check(strings.Join(t1.Log(), ""), Matches, `.*handler error for "foo"`)
c.Check(called, Equals, true)

c.Check(logbuf.String(), Matches, `(?m).*: \[change 1 "task summary" task\] failed: handler error for "foo".*`)
c.Check(logbuf.String(), Matches, `(?m).*: Change 1 task \(task summary\) failed: handler error for "foo".*`)
}

func (ts *taskRunnerSuite) TestErrorCallbackNotCalled(c *C) {
Expand Down

0 comments on commit 0d00024

Please sign in to comment.