fixes #744 no-shim will crash containerd with ctr list and ctr info
Signed-off-by: Krasi Georgiev <krasi.root@gmail.com>
This commit is contained in:
parent
19edcb72b5
commit
0e7e89c0f1
@ -24,7 +24,7 @@ import (
|
||||
|
||||
func newShim(path string, remote bool) (shim.ShimClient, error) {
|
||||
if !remote {
|
||||
return localShim.Client(path), nil
|
||||
return localShim.Client(path)
|
||||
}
|
||||
socket := filepath.Join(path, "shim.sock")
|
||||
l, err := sys.CreateUnixSocket(socket)
|
||||
@ -59,7 +59,7 @@ func newShim(path string, remote bool) (shim.ShimClient, error) {
|
||||
|
||||
func loadShim(path string, remote bool) (shim.ShimClient, error) {
|
||||
if !remote {
|
||||
return localShim.Client(path), nil
|
||||
return localShim.Client(path)
|
||||
}
|
||||
socket := filepath.Join(path, "shim.sock")
|
||||
return connectShim(socket)
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
shimapi "github.com/containerd/containerd/api/services/shim"
|
||||
"github.com/containerd/containerd/api/types/container"
|
||||
runc "github.com/crosbymichael/go-runc"
|
||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/sys/unix"
|
||||
@ -12,10 +13,26 @@ import (
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
func Client(path string) shimapi.ShimClient {
|
||||
return &client{
|
||||
func Client(path string) (shimapi.ShimClient, error) {
|
||||
pid, err := runc.ReadPidFile(filepath.Join(path, "init.pid"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cl := &client{
|
||||
s: New(path),
|
||||
}
|
||||
|
||||
// used when quering container status and info
|
||||
cl.s.initProcess = &initProcess{
|
||||
id: filepath.Base(path),
|
||||
pid: pid,
|
||||
runc: &runc.Runc{
|
||||
Log: filepath.Join(path, "log.json"),
|
||||
LogFormat: runc.JSON,
|
||||
},
|
||||
}
|
||||
return cl, nil
|
||||
}
|
||||
|
||||
type client struct {
|
||||
|
Loading…
Reference in New Issue
Block a user