Skip to content

Commit

Permalink
runtime: Short the shim-monitor path
Browse files Browse the repository at this point in the history
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: kata-containers#497

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
  • Loading branch information
fidencio authored and egernst committed May 7, 2021
1 parent 0a3b793 commit 4bc006c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/runtime/cli/kata-exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
7 changes: 1 addition & 6 deletions src/runtime/containerd-shim-v2/shim_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit 4bc006c

Please sign in to comment.