From 4bc006c8a4911c2053f47889f7ef7069c7fb7418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Tue, 2 Mar 2021 14:33:25 +0100 Subject: [PATCH] runtime: Short the shim-monitor path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of having something like "/containerd-shim/$namespace/$sandboxID/shim-monitor.sock", let's change the approach to: * create the file in a more neutral location "/run/vc", instead of "/containerd-shim"; * drop the namespace, as the sandboxID should be unique; * remove ".sock" from the socket name. This will result on a name that looks like: "/run/vc/$sandboxID/shim-monitor" Fixes: #497 Signed-off-by: Fabiano FidĂȘncio --- src/runtime/cli/kata-exec.go | 9 ++++++--- src/runtime/containerd-shim-v2/shim_management.go | 7 +------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/runtime/cli/kata-exec.go b/src/runtime/cli/kata-exec.go index d556f782ac..dba2e8f299 100644 --- a/src/runtime/cli/kata-exec.go +++ b/src/runtime/cli/kata-exec.go @@ -26,6 +26,7 @@ import ( clientUtils "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/agent/protocols/client" "github.com/pkg/errors" "github.com/urfave/cli" + "go.opentelemetry.io/otel/label" ) const ( @@ -82,7 +83,9 @@ var kataExecCLICommand = cli.Command{ return err } - conn, err := getConn(namespace, sandboxID, port) + span.SetAttributes(label.Key("sandbox").String(sandboxID)) + conn, err := getConn(sandboxID, port) + if err != nil { return err } @@ -165,8 +168,8 @@ func (s *iostream) Read(data []byte) (n int, err error) { return s.conn.Read(data) } -func getConn(namespace, sandboxID string, port uint64) (net.Conn, error) { - socketAddr := filepath.Join(string(filepath.Separator), "containerd-shim", namespace, sandboxID, "shim-monitor.sock") +func getConn(sandboxID string, port uint64) (net.Conn, error) { + socketAddr := filepath.Join(string(filepath.Separator), "run", "vc", sandboxID, "shim-monitor") client, err := kataMonitor.BuildUnixSocketClient(socketAddr, defaultTimeout) if err != nil { return nil, err diff --git a/src/runtime/containerd-shim-v2/shim_management.go b/src/runtime/containerd-shim-v2/shim_management.go index d7b4bb1cac..7be8af41d7 100644 --- a/src/runtime/containerd-shim-v2/shim_management.go +++ b/src/runtime/containerd-shim-v2/shim_management.go @@ -16,7 +16,6 @@ import ( "strconv" "strings" - "github.com/containerd/containerd/namespaces" cdshim "github.com/containerd/containerd/runtime/v2/shim" vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers" vcAnnotations "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/annotations" @@ -189,9 +188,5 @@ func (s *service) mountPprofHandle(m *http.ServeMux, ociSpec *specs.Spec) { } func socketAddress(ctx context.Context, id string) (string, error) { - ns, err := namespaces.NamespaceRequired(ctx) - if err != nil { - return "", err - } - return filepath.Join(string(filepath.Separator), "containerd-shim", ns, id, "shim-monitor.sock"), nil + return filepath.Join(string(filepath.Separator), "run", "vc", id, "shim-monitor"), nil }