Merge pull request #788 from krasi-georgiev/#744-no-shim-crash-with-ctr-list
fixes #744 no-shim will crash containerd with ctr list and ctr info
This commit is contained in:
commit
92af03f193
@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
func newShim(path string, remote bool) (shim.ShimClient, error) {
|
func newShim(path string, remote bool) (shim.ShimClient, error) {
|
||||||
if !remote {
|
if !remote {
|
||||||
return localShim.Client(path), nil
|
return localShim.Client(path)
|
||||||
}
|
}
|
||||||
socket := filepath.Join(path, "shim.sock")
|
socket := filepath.Join(path, "shim.sock")
|
||||||
l, err := sys.CreateUnixSocket(socket)
|
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) {
|
func loadShim(path string, remote bool) (shim.ShimClient, error) {
|
||||||
if !remote {
|
if !remote {
|
||||||
return localShim.Client(path), nil
|
return localShim.Client(path)
|
||||||
}
|
}
|
||||||
socket := filepath.Join(path, "shim.sock")
|
socket := filepath.Join(path, "shim.sock")
|
||||||
return connectShim(socket)
|
return connectShim(socket)
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
|
|
||||||
shimapi "github.com/containerd/containerd/api/services/shim"
|
shimapi "github.com/containerd/containerd/api/services/shim"
|
||||||
"github.com/containerd/containerd/api/types/container"
|
"github.com/containerd/containerd/api/types/container"
|
||||||
|
runc "github.com/crosbymichael/go-runc"
|
||||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
@ -12,10 +13,26 @@ import (
|
|||||||
"google.golang.org/grpc/metadata"
|
"google.golang.org/grpc/metadata"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Client(path string) shimapi.ShimClient {
|
func Client(path string) (shimapi.ShimClient, error) {
|
||||||
return &client{
|
pid, err := runc.ReadPidFile(filepath.Join(path, "init.pid"))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
cl := &client{
|
||||||
s: New(path),
|
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 {
|
type client struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user