Browse code

Merge pull request #407 from thaJeztah/19.03_backport_better_container_error

[19.03 backport] Propagate GetContainer error from event processor

Andrew Hsu authored on 2019/10/29 02:50:46
Showing 1 changed files
... ...
@@ -2,8 +2,6 @@ package daemon // import "github.com/docker/docker/daemon"
2 2
 
3 3
 import (
4 4
 	"context"
5
-	"errors"
6
-	"fmt"
7 5
 	"runtime"
8 6
 	"strconv"
9 7
 	"time"
... ...
@@ -12,6 +10,7 @@ import (
12 12
 	"github.com/docker/docker/container"
13 13
 	libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
14 14
 	"github.com/docker/docker/restartmanager"
15
+	"github.com/pkg/errors"
15 16
 	"github.com/sirupsen/logrus"
16 17
 )
17 18
 
... ...
@@ -29,8 +28,8 @@ func (daemon *Daemon) setStateCounter(c *container.Container) {
29 29
 // ProcessEvent is called by libcontainerd whenever an event occurs
30 30
 func (daemon *Daemon) ProcessEvent(id string, e libcontainerdtypes.EventType, ei libcontainerdtypes.EventInfo) error {
31 31
 	c, err := daemon.GetContainer(id)
32
-	if c == nil || err != nil {
33
-		return fmt.Errorf("no such container: %s", id)
32
+	if err != nil {
33
+		return errors.Wrapf(err, "could not find container %s", id)
34 34
 	}
35 35
 
36 36
 	switch e {