Skip to content

Commit

Permalink
set tracing socket path to runtime dir
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Jul 31, 2023
1 parent 9da03ce commit 0e83310
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/buildkitd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ func newController(c *cli.Context, cfg *config.Config) (*control.Controller, err

var traceSocket string
if tc != nil {
traceSocket = traceSocketPath(cfg.Root)
traceSocket = traceSocketPath(userns.RunningInUserNS())
if err := runTraceController(traceSocket, tc); err != nil {
return nil, err
}
Expand Down
11 changes: 9 additions & 2 deletions cmd/buildkitd/main_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net"
"os"
"path/filepath"
"strings"
"syscall"

"github.com/containerd/containerd/sys"
Expand Down Expand Up @@ -47,8 +48,14 @@ func listenFD(addr string, tlsConfig *tls.Config) (net.Listener, error) {
return nil, errors.New("not supported yet")
}

func traceSocketPath(root string) string {
return filepath.Join(root, "otel-grpc.sock")
func traceSocketPath(inUserNS bool) string {
if inUserNS {
if xrd := os.Getenv("XDG_RUNTIME_DIR"); xrd != "" {
dirs := strings.Split(xrd, ":")
return filepath.Join(dirs[0], "buildkit", "otel-grpc.sock")
}
}
return "/run/buildkit/otel-grpc.sock"
}

func getLocalListener(listenerPath string) (net.Listener, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/buildkitd/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func listenFD(addr string, tlsConfig *tls.Config) (net.Listener, error) {
return nil, errors.New("listening server on fd not supported on windows")
}

func traceSocketPath(root string) string {
func traceSocketPath(inUserNS bool) string {
return defaultTraceSocketPath
}

Expand Down

0 comments on commit 0e83310

Please sign in to comment.