diff --git a/cmd/gotemplate/gotemplate_test.go b/cmd/gotemplate/gotemplate_test.go index 3322702ad96..2e2073da413 100644 --- a/cmd/gotemplate/gotemplate_test.go +++ b/cmd/gotemplate/gotemplate_test.go @@ -21,6 +21,7 @@ import ( "os" "path" "strings" + "syscall" "testing" "github.com/stretchr/testify/assert" @@ -28,6 +29,7 @@ import ( ) func TestGenerate(t *testing.T) { + noFileErr := os.PathError{Op: "open", Path: "no-such-file.txt", Err: syscall.Errno(syscall.ENOENT)} for name, tt := range map[string]struct { in string data map[string]string @@ -37,7 +39,7 @@ func TestGenerate(t *testing.T) { }{ "missing-file": { in: `{{include "no-such-file.txt"}}`, - expectedErr: "open no-such-file.txt: no such file or directory", + expectedErr: noFileErr.Error(), }, "data": { in: `{{.Hello}} {{.World}}`, diff --git a/cmd/kube-proxy/app/server_windows.go b/cmd/kube-proxy/app/server_windows.go index 7d77d0c0b1c..fcd21353ea9 100644 --- a/cmd/kube-proxy/app/server_windows.go +++ b/cmd/kube-proxy/app/server_windows.go @@ -41,6 +41,9 @@ func (o *Options) platformApplyDefaults(config *proxyconfigapi.KubeProxyConfigur if config.Mode == "" { config.Mode = proxyconfigapi.ProxyModeKernelspace } + if config.Winkernel.RootHnsEndpointName == "" { + config.Winkernel.RootHnsEndpointName = "cbr0" + } } // platformSetup is called after setting up the ProxyServer, but before creating the diff --git a/cmd/kube-scheduler/app/options/configfile_test.go b/cmd/kube-scheduler/app/options/configfile_test.go index eb7bf84e3a3..dd1ae6e620f 100644 --- a/cmd/kube-scheduler/app/options/configfile_test.go +++ b/cmd/kube-scheduler/app/options/configfile_test.go @@ -21,6 +21,7 @@ import ( "fmt" "os" "path/filepath" + "syscall" "testing" "github.com/stretchr/testify/assert" @@ -32,7 +33,6 @@ const ( apiVersionMissing = "'apiVersion' is missing" apiVersionTooOld = "no kind \"KubeSchedulerConfiguration\" is registered for" + " version \"kubescheduler.config.k8s.io/v1alpha1\"" - fileNotFound = "no such file or directory" // schedulerConfigMinimalCorrect is the minimal // correct scheduler config @@ -91,7 +91,7 @@ func TestLoadConfigFromFile(t *testing.T) { { name: "Empty scheduler config file path", path: "", - expectedErr: fmt.Errorf(fileNotFound), + expectedErr: syscall.Errno(syscall.ENOENT), expectedConfig: nil, }, { diff --git a/pkg/kubeapiserver/options/authentication_test.go b/pkg/kubeapiserver/options/authentication_test.go index c2b06c3950e..94f0c7e694c 100644 --- a/pkg/kubeapiserver/options/authentication_test.go +++ b/pkg/kubeapiserver/options/authentication_test.go @@ -20,6 +20,7 @@ import ( "os" "reflect" "strings" + "syscall" "testing" "time" @@ -905,7 +906,7 @@ func TestLoadAuthenticationConfig(t *testing.T) { { name: "missing file", file: func() string { return "bogus-missing-file" }, - expectErr: "no such file or directory", + expectErr: syscall.Errno(syscall.ENOENT).Error(), expectedConfig: nil, }, { @@ -1037,6 +1038,10 @@ func writeTempFile(t *testing.T, content string) string { t.Fatal(err) } t.Cleanup(func() { + // An open file cannot be removed on Windows. Close it first. + if err := file.Close(); err != nil { + t.Fatal(err) + } if err := os.Remove(file.Name()); err != nil { t.Fatal(err) } diff --git a/pkg/kubelet/server/stats/summary_windows_test.go b/pkg/kubelet/server/stats/summary_windows_test.go index 00d2355bc61..e840fe12380 100644 --- a/pkg/kubelet/server/stats/summary_windows_test.go +++ b/pkg/kubelet/server/stats/summary_windows_test.go @@ -64,7 +64,7 @@ func TestSummaryProvider(t *testing.T) { mockStatsProvider.EXPECT().GetPodCgroupRoot().Return(cgroupRoot).AnyTimes() mockStatsProvider.EXPECT().ListPodStats(ctx).Return(podStats, nil).AnyTimes() mockStatsProvider.EXPECT().ListPodStatsAndUpdateCPUNanoCoreUsage(ctx).Return(podStats, nil).AnyTimes() - mockStatsProvider.EXPECT().ImageFsStats(ctx).Return(imageFsStats, nil).AnyTimes() + mockStatsProvider.EXPECT().ImageFsStats(ctx).Return(imageFsStats, ImageFsStats, nil).AnyTimes() mockStatsProvider.EXPECT().RootFsStats().Return(rootFsStats, nil).AnyTimes() mockStatsProvider.EXPECT().RlimitStats().Return(nil, nil).AnyTimes() mockStatsProvider.EXPECT().GetCgroupStats("/", true).Return(cgroupStatsMap["/"].cs, cgroupStatsMap["/"].ns, nil).AnyTimes() @@ -81,7 +81,7 @@ func TestSummaryProvider(t *testing.T) { assert.Equal(summary.Node.Memory, cgroupStatsMap["/"].cs.Memory) assert.Equal(summary.Node.Network, cgroupStatsMap["/"].ns) assert.Equal(summary.Node.Fs, rootFsStats) - assert.Equal(summary.Node.Runtime, &statsapi.RuntimeStats{ImageFs: imageFsStats}) + assert.Equal(summary.Node.Runtime, &statsapi.RuntimeStats{ContainerFs: imageFsStats, ImageFs: imageFsStats}) assert.Equal(len(summary.Node.SystemContainers), 1) assert.Equal(summary.Node.SystemContainers[0].Name, "pods") diff --git a/pkg/volume/util/hostutil/hostutil.go b/pkg/volume/util/hostutil/hostutil.go index 6624fc616e5..4539afd7086 100644 --- a/pkg/volume/util/hostutil/hostutil.go +++ b/pkg/volume/util/hostutil/hostutil.go @@ -41,6 +41,10 @@ const ( FileTypeUnknown FileType = "" ) +var ( + errUnknownFileType = fmt.Errorf("only recognise file, directory, socket, block device and character device") +) + // HostUtils defines the set of methods for interacting with paths on a host. type HostUtils interface { // DeviceOpened determines if the device (e.g. /dev/sdc) is in use elsewhere @@ -109,5 +113,5 @@ func getFileType(pathname string) (FileType, error) { return FileTypeBlockDev, nil } - return pathType, fmt.Errorf("only recognise file, directory, socket, block device and character device") + return pathType, errUnknownFileType } diff --git a/pkg/volume/util/hostutil/hostutil_windows.go b/pkg/volume/util/hostutil/hostutil_windows.go index c8f35a1737c..27bc8b212b9 100644 --- a/pkg/volume/util/hostutil/hostutil_windows.go +++ b/pkg/volume/util/hostutil/hostutil_windows.go @@ -105,7 +105,7 @@ func (hu *(HostUtil)) GetFileType(pathname string) (FileType, error) { // os.Stat will return a 1920 error (windows.ERROR_CANT_ACCESS_FILE) if we use it on a Unix Socket // on Windows. In this case, we need to use a different method to check if it's a Unix Socket. - if isSystemCannotAccessErr(err) { + if err == errUnknownFileType || isSystemCannotAccessErr(err) { if isSocket, errSocket := filesystem.IsUnixDomainSocket(pathname); errSocket == nil && isSocket { return FileTypeSocket, nil }