Skip to content

Commit

Permalink
fix(windows): create debug npipe failure
Browse files Browse the repository at this point in the history
Signed-off-by: Weijia Mai <[email protected]>
  • Loading branch information
thxCode committed Apr 14, 2021
1 parent f968359 commit 2de38a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/containerd/command/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ can be used and modified as necessary as a custom configuration.`

if config.Debug.Address != "" {
var l net.Listener
if filepath.IsAbs(config.Debug.Address) {
if isLocalAddress(config.Debug.Address) {
if l, err = sys.GetLocalListener(config.Debug.Address, config.Debug.UID, config.Debug.GID); err != nil {
return errors.Wrapf(err, "failed to get listener for debug endpoint")
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/containerd/command/main_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package command
import (
"context"
"os"
"path/filepath"

"github.com/containerd/containerd/log"
"github.com/containerd/containerd/services/server"
Expand Down Expand Up @@ -72,3 +73,7 @@ func handleSignals(ctx context.Context, signals chan os.Signal, serverC chan *se
}()
return done
}

func isLocalAddress(path string) bool {
return filepath.IsAbs(path)
}
5 changes: 5 additions & 0 deletions cmd/containerd/command/main_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"
"os"
"strings"
"unsafe"

"github.com/Microsoft/go-winio/pkg/etw"
Expand Down Expand Up @@ -117,3 +118,7 @@ func init() {
}
}
}

func isLocalAddress(path string) bool {
return strings.HasPrefix(path, `\\.\pipe\`)
}

0 comments on commit 2de38a9

Please sign in to comment.