Skip to content

Commit

Permalink
Switch Windows default runtime endpoints to npipe
Browse files Browse the repository at this point in the history
  • Loading branch information
feiskyer committed Oct 31, 2018
1 parent c616b23 commit d29300b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 55 deletions.
3 changes: 2 additions & 1 deletion cmd/crictl/main.go
Expand Up @@ -28,6 +28,7 @@ import (
"google.golang.org/grpc"
"k8s.io/kubernetes/pkg/kubelet/apis/cri"
"k8s.io/kubernetes/pkg/kubelet/remote"
"k8s.io/kubernetes/pkg/kubelet/util"

"github.com/kubernetes-sigs/cri-tools/pkg/version"
)
Expand All @@ -52,7 +53,7 @@ func getRuntimeClientConnection(context *cli.Context) (*grpc.ClientConn, error)
return nil, fmt.Errorf("--runtime-endpoint is not set")
}

addr, dialer, err := GetAddressAndDialer(RuntimeEndpoint)
addr, dialer, err := util.GetAddressAndDialer(RuntimeEndpoint)
if err != nil {
return nil, err
}
Expand Down
23 changes: 0 additions & 23 deletions cmd/crictl/main_unix.go
Expand Up @@ -18,30 +18,7 @@ limitations under the License.

package main

import (
"net"
"time"

"k8s.io/kubernetes/pkg/kubelet/util"
)

const (
defaultConfigPath = "/etc/crictl.yaml"
defaultRuntimeEndpoint = "unix:///var/run/dockershim.sock"
)

// GetAddressAndDialer returns the address and a dialer for the endpoint
// protocol.
//
// On Unix supported protocols are unix sockets.
//
// Examples:
//
// An endpoint of "unix:///var/run/dockershim.sock" returns address
// "/var/run/dockershim.sock" and a unix socket dialer for this address.
//
// An endpoint of "/var/run/dockershim.sock" returns address
// "/var/run/dockershim.sock" and a unix socket dialer for this address.
func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout time.Duration) (net.Conn, error), error) {
return util.GetAddressAndDialer(endpoint)
}
31 changes: 1 addition & 30 deletions cmd/crictl/main_windows.go
Expand Up @@ -19,45 +19,16 @@ limitations under the License.
package main

import (
"net"
"os"
"path/filepath"
"strings"
"time"

"github.com/Microsoft/go-winio"
"k8s.io/kubernetes/pkg/kubelet/util"
)

const (
defaultRuntimeEndpoint = "tcp://localhost:3735"
defaultRuntimeEndpoint = "npipe:////./pipe/dockershim"
)

var defaultConfigPath string

func init() {
defaultConfigPath = filepath.Join(os.Getenv("USERPROFILE"), ".crictl", "crictl.yaml")
}

// GetAddressAndDialer returns the address and a dialer for the endpoint
// protocol.
//
// On Windows supported protocols are Windows named pipes and tcp.
//
// Examples:
//
// An endpoint of "tcp://localhost:3735" returns address "localhost:3735" and a
// tcp socket dialer for this address.
//
// An endpoint of "\\.\pipe\name" returns an address of "\\.\pipe\name" and a
// Windows named pipe dialer for this address.
func GetAddressAndDialer(endpoint string) (string, func(addr string, timeout time.Duration) (net.Conn, error), error) {
if strings.HasPrefix(endpoint, "\\\\.\\pipe") {
return endpoint, dial, nil
}
return util.GetAddressAndDialer(endpoint)
}

func dial(addr string, timeout time.Duration) (net.Conn, error) {
return winio.DialPipe(addr, &timeout)
}
2 changes: 1 addition & 1 deletion pkg/framework/test_context.go
Expand Up @@ -61,7 +61,7 @@ func RegisterFlags() {

svcaddr := "unix:///var/run/dockershim.sock"
if runtime.GOOS == "windows" {
svcaddr = "tcp://localhost:3735"
svcaddr = "npipe:////./pipe/dockershim"
}
flag.StringVar(&TestContext.RuntimeServiceAddr, "runtime-endpoint", svcaddr, "Runtime service socket for client to connect..")
flag.DurationVar(&TestContext.RuntimeServiceTimeout, "runtime-service-timeout", 300*time.Second, "Timeout when trying to connect to a runtime service.")
Expand Down

0 comments on commit d29300b

Please sign in to comment.