mirror of https://github.com/docker/docs.git
Merge pull request #22058 from WeiZhang555/remove-rpc-error
Remove rpc error when shut down daemon
This commit is contained in:
commit
dadc3087e3
|
|
@ -23,6 +23,7 @@ import (
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
|
"google.golang.org/grpc/transport"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -37,17 +38,18 @@ const (
|
||||||
|
|
||||||
type remote struct {
|
type remote struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
apiClient containerd.APIClient
|
apiClient containerd.APIClient
|
||||||
daemonPid int
|
daemonPid int
|
||||||
stateDir string
|
stateDir string
|
||||||
rpcAddr string
|
rpcAddr string
|
||||||
startDaemon bool
|
startDaemon bool
|
||||||
debugLog bool
|
closeManually bool
|
||||||
rpcConn *grpc.ClientConn
|
debugLog bool
|
||||||
clients []*client
|
rpcConn *grpc.ClientConn
|
||||||
eventTsPath string
|
clients []*client
|
||||||
pastEvents map[string]*containerd.Event
|
eventTsPath string
|
||||||
runtimeArgs []string
|
pastEvents map[string]*containerd.Event
|
||||||
|
runtimeArgs []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a fresh instance of libcontainerd remote.
|
// New creates a fresh instance of libcontainerd remote.
|
||||||
|
|
@ -147,6 +149,7 @@ func (r *remote) Cleanup() {
|
||||||
if r.daemonPid == -1 {
|
if r.daemonPid == -1 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
r.closeManually = true
|
||||||
r.rpcConn.Close()
|
r.rpcConn.Close()
|
||||||
// Ask the daemon to quit
|
// Ask the daemon to quit
|
||||||
syscall.Kill(r.daemonPid, syscall.SIGTERM)
|
syscall.Kill(r.daemonPid, syscall.SIGTERM)
|
||||||
|
|
@ -254,6 +257,11 @@ func (r *remote) handleEventStream(events containerd.API_EventsClient) {
|
||||||
for {
|
for {
|
||||||
e, err := events.Recv()
|
e, err := events.Recv()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if grpc.ErrorDesc(err) == transport.ErrConnClosing.Desc &&
|
||||||
|
r.closeManually {
|
||||||
|
// ignore error if grpc remote connection is closed manually
|
||||||
|
return
|
||||||
|
}
|
||||||
logrus.Errorf("failed to receive event from containerd: %v", err)
|
logrus.Errorf("failed to receive event from containerd: %v", err)
|
||||||
go r.startEventsMonitor()
|
go r.startEventsMonitor()
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue