RPC connection closing error will be reported every time we shutdown
daemon, this error is expected, so we should remove this error to avoid
confusion to user.
Signed-off-by: Zhang Wei <zhangwei555@huawei.com>
| ... | ... |
@@ -23,6 +23,7 @@ import ( |
| 23 | 23 |
"golang.org/x/net/context" |
| 24 | 24 |
"google.golang.org/grpc" |
| 25 | 25 |
"google.golang.org/grpc/grpclog" |
| 26 |
+ "google.golang.org/grpc/transport" |
|
| 26 | 27 |
) |
| 27 | 28 |
|
| 28 | 29 |
const ( |
| ... | ... |
@@ -37,17 +38,18 @@ const ( |
| 37 | 37 |
|
| 38 | 38 |
type remote struct {
|
| 39 | 39 |
sync.RWMutex |
| 40 |
- apiClient containerd.APIClient |
|
| 41 |
- daemonPid int |
|
| 42 |
- stateDir string |
|
| 43 |
- rpcAddr string |
|
| 44 |
- startDaemon bool |
|
| 45 |
- debugLog bool |
|
| 46 |
- rpcConn *grpc.ClientConn |
|
| 47 |
- clients []*client |
|
| 48 |
- eventTsPath string |
|
| 49 |
- pastEvents map[string]*containerd.Event |
|
| 50 |
- runtimeArgs []string |
|
| 40 |
+ apiClient containerd.APIClient |
|
| 41 |
+ daemonPid int |
|
| 42 |
+ stateDir string |
|
| 43 |
+ rpcAddr string |
|
| 44 |
+ startDaemon bool |
|
| 45 |
+ closeManually bool |
|
| 46 |
+ debugLog bool |
|
| 47 |
+ rpcConn *grpc.ClientConn |
|
| 48 |
+ clients []*client |
|
| 49 |
+ eventTsPath string |
|
| 50 |
+ pastEvents map[string]*containerd.Event |
|
| 51 |
+ runtimeArgs []string |
|
| 51 | 52 |
} |
| 52 | 53 |
|
| 53 | 54 |
// New creates a fresh instance of libcontainerd remote. |
| ... | ... |
@@ -147,6 +149,7 @@ func (r *remote) Cleanup() {
|
| 147 | 147 |
if r.daemonPid == -1 {
|
| 148 | 148 |
return |
| 149 | 149 |
} |
| 150 |
+ r.closeManually = true |
|
| 150 | 151 |
r.rpcConn.Close() |
| 151 | 152 |
// Ask the daemon to quit |
| 152 | 153 |
syscall.Kill(r.daemonPid, syscall.SIGTERM) |
| ... | ... |
@@ -254,6 +257,11 @@ func (r *remote) handleEventStream(events containerd.API_EventsClient) {
|
| 254 | 254 |
for {
|
| 255 | 255 |
e, err := events.Recv() |
| 256 | 256 |
if err != nil {
|
| 257 |
+ if grpc.ErrorDesc(err) == transport.ErrConnClosing.Desc && |
|
| 258 |
+ r.closeManually {
|
|
| 259 |
+ // ignore error if grpc remote connection is closed manually |
|
| 260 |
+ return |
|
| 261 |
+ } |
|
| 257 | 262 |
logrus.Errorf("failed to receive event from containerd: %v", err)
|
| 258 | 263 |
go r.startEventsMonitor() |
| 259 | 264 |
return |