containerd-shim: Use abstract namespace for the unix socket

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2017-06-12 14:43:28 -07:00
parent 8644a08c96
commit 95afeb7831
4 changed files with 63 additions and 26 deletions

View File

@@ -44,12 +44,14 @@ func newBundle(path, namespace, id string, spec []byte) (b *bundle, err error) {
defer f.Close()
_, err = io.Copy(f, bytes.NewReader(spec))
return &bundle{
id: id,
path: path,
namespace: namespace,
}, err
}
type bundle struct {
id string
path string
namespace string
}
@@ -61,7 +63,7 @@ func (b *bundle) NewShim(ctx context.Context, binary string, remote bool) (*clie
opt = client.WithLocal
}
return client.New(ctx, client.Config{
Address: filepath.Join(b.path, "shim.sock"),
Address: b.shimAddress(),
Path: b.path,
Namespace: b.namespace,
}, opt)
@@ -74,7 +76,7 @@ func (b *bundle) Connect(ctx context.Context, remote bool) (*client.Client, erro
opt = client.WithLocal
}
return client.New(ctx, client.Config{
Address: filepath.Join(b.path, "shim.sock"),
Address: b.shimAddress(),
Path: b.path,
Namespace: b.namespace,
}, opt)
@@ -89,3 +91,8 @@ func (b *bundle) Spec() ([]byte, error) {
func (b *bundle) Delete() error {
return os.RemoveAll(b.path)
}
func (b *bundle) shimAddress() string {
return filepath.Join(string(filepath.Separator), "containerd-shim", b.namespace, b.id, "shim.sock")
}