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 3970ecf commit e3ebc8a
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 58 deletions.
5 changes: 3 additions & 2 deletions cmd/crictl/main.go
Original file line number Diff line number Diff line change
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 All @@ -72,7 +73,7 @@ func getImageClientConnection(context *cli.Context) (*grpc.ClientConn, error) {
ImageEndpoint = RuntimeEndpoint
}

addr, dialer, err := GetAddressAndDialer(ImageEndpoint)
addr, dialer, err := util.GetAddressAndDialer(ImageEndpoint)
if err != nil {
return nil, err
}
Expand Down
23 changes: 0 additions & 23 deletions cmd/crictl/main_unix.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)
}
3 changes: 2 additions & 1 deletion pkg/benchmark/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ var _ = framework.KubeDescribe("PodSandbox", func() {
Linux: &runtimeapi.LinuxPodSandboxConfig{},
}

// TODO: add support of runtime
operation := b.Time("create PodSandbox", func() {
podID, err = c.RunPodSandbox(config)
podID, err = c.RunPodSandbox(config, "")
})

framework.ExpectNoError(err, "failed to create PodSandbox: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/framework/test_context.go
Original file line number Diff line number Diff line change
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
3 changes: 2 additions & 1 deletion pkg/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ func BuildPodSandboxMetadata(podSandboxName, uid, namespace string, attempt uint

// RunPodSandbox runs a PodSandbox.
func RunPodSandbox(c internalapi.RuntimeService, config *runtimeapi.PodSandboxConfig) string {
podID, err := c.RunPodSandbox(config)
// TODO: add support of runtime handler.
podID, err := c.RunPodSandbox(config, "")
ExpectNoError(err, "failed to create PodSandbox: %v", err)
return podID
}
Expand Down

0 comments on commit e3ebc8a

Please sign in to comment.