Repository: kubernetes/kubernetes (language: go)

Issue:
Sweep and adjust Stat/Lstat/EvalSymlinks to go 1.23 behavior on Windows
Context: https://github.com/kubernetes/kubernetes/issues/129080

Go 1.23 changed stdlib behavior of filesystem calls Stat / Lstat / EvalSymlinks on Windows. This broke some kubelet handling of volumes on Windows, and possibly other use of those functions. For Kubernetes 1.32, the behavior was temporarily reverted via godebug switches in https://github.com/kubernetes/kubernetes/pull/129083, but this is not a long-term solution. Libraries like [k8s.io/mount-utils](https://github.com/kubernetes/mount-utils) can be used by downstream consumers building with go 1.23 and get unintended behavior, and the godebug opt-outs will eventually become unavailable, so we need to prepare Kubernetes to not require them as soon as possible.

As soon as possible in the 1.33 development cycle, sig-storage / sig-windows / sig-node need to sweep for use of Stat / Lstat / EvalSymlinks calls that would be impacted by the go 1.23 changes, and adjust them to work properly, and drop the change in https://github.com/kubernetes/kubernetes/pull/129083 to restore default go stdlib behavior.

A prereq to doing this safely is good test coverage (both unit test level and e2e level).
- There is currently no job running unit tests on Windows
- There are some e2e jobs exercising volumes on Windows, but the one that was broken (GCE PD) does not currently have working tests (see https://github.com/kubernetes/kubernetes/issues/129080#issuecomment-2517810676 and https://github.com/kubernetes/test-infra/issues/33905)

/sig node storage windows
/priority important-soon
/milestone v1.33


Discussion / hints:
/assign @msau42 @marosset

for routing / planning for 1.33
> There is currently no job running unit tests on Windows

Last time this came up, we discussed getting a job into release-informing => blocking, but I don't think that came through yet. That was in https://github.com/kubernetes/test-infra/pull/32689#pullrequestreview-2202592050


/triage accepted
https://prow.k8s.io/?job=ci-kubernetes-unit-windows-master
1. "passes" even when tests are failing / fails to report overall failure.
2. Consistently has >90 tests failing (by inspecting junit results).
3. Takes 2-3h and is therefore too slow for release-blocking. (Can we throw a bigger windows VM at this or something?)

Is anyone working on this? cc @kubernetes/sig-windows-leads 
> * Consistently has >90 tests failing (by inspecting junit results).

~50 of those will be fixed by https://github.com/kubernetes/kubernetes/pull/129252
> https://prow.k8s.io/?job=ci-kubernetes-unit-windows-master
> 
> 1. "passes" even when tests are failing / fails to report overall failure.
> 2. Consistently has >90 tests failing (by inspecting junit results).
> 3. Takes 2-3h and is therefore too slow for release-blocking. (Can we throw a bigger windows VM at this or something?)
> 
> Is anyone working on this? cc @kubernetes/sig-windows-leads

Just wondering how long in general it will take to run unit tests under linux?
https://prow.k8s.io/?job=ci-kubernetes-unit

about ~40-45 minutes
We're getting close to wanting to pick up go 1.24 in master (https://github.com/kubernetes/kubernetes/pull/129688#issuecomment-2599843135) and actually finishing this to get master on go 1.23 compatibly seems really important

Who is driving completion of this issue and what is the time frame for it?
@mansikulkarni96 will take a look at the kubelet side of things. @andyzhangx is looking at the storage side. So together this should be driven to completion. 
/assign @mansikulkarni96 
[fix: adopt go1.23 behavior change in mount point parsing on Windows#2 by andyzhangx · Pull Request #129370 · kubernetes/kubernetes](https://github.com/kubernetes/kubernetes/pull/129370)
I filed https://github.com/kubernetes-sigs/windows-testing/issues/472 to track:
> 1. "passes" even when tests are failing / fails to report overall failure.

and ask / suggest about:
> 3. Takes 2-3h and is therefore too slow for release-blocking. (Can we throw a bigger windows VM at this or something?)

> [@mansikulkarni96](https://github.com/mansikulkarni96) will take a look at the kubelet side of things. [@andyzhangx](https://github.com/andyzhangx) is looking at the storage side. So together this should be driven to completion.

Thanks, what is the timeframe for doing this sweep? Go 1.24 will be releasing in February (so in just a few weeks)... completely landing on Go 1.23 by resolving this issue ahead of that is important.
@liggitt I am working on doing the sweep, will try to open a PR as soon as possible.

Fix patch:
diff --git a/go.mod b/go.mod
index 158bffe95fcc6..e8dfb5cc8a7f3 100644
--- a/go.mod
+++ b/go.mod
@@ -10,8 +10,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	bitbucket.org/bertimus9/systemstat v0.5.0
 	github.com/JeffAshton/win_pdh v0.0.0-20161109143554-76bb4ee9f0ab
diff --git a/go.work b/go.work
index 08d4697e45efa..d48c8b6b2716d 100644
--- a/go.work
+++ b/go.work
@@ -4,8 +4,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 use (
 	.
 	./staging/src/k8s.io/api
diff --git a/pkg/kubelet/cm/devicemanager/manager.go b/pkg/kubelet/cm/devicemanager/manager.go
index 5f4a72a43e395..9ed9c132293cb 100644
--- a/pkg/kubelet/cm/devicemanager/manager.go
+++ b/pkg/kubelet/cm/devicemanager/manager.go
@@ -202,15 +202,12 @@ func (m *ManagerImpl) CleanupPluginDirectory(dir string) error {
 		if filePath == m.checkpointFile() {
 			continue
 		}
-		// TODO: Until the bug - https://github.com/golang/go/issues/33357 is fixed, os.stat wouldn't return the
-		// right mode(socket) on windows. Hence deleting the file, without checking whether
-		// its a socket, on windows.
-		stat, err := os.Lstat(filePath)
+		stat, err := os.Stat(filePath)
 		if err != nil {
 			klog.ErrorS(err, "Failed to stat file", "path", filePath)
 			continue
 		}
-		if stat.IsDir() {
+		if stat.IsDir() || stat.Mode()&os.ModeSocket == 0 {
 			continue
 		}
 		err = os.RemoveAll(filePath)
diff --git a/pkg/util/filesystem/util_windows.go b/pkg/util/filesystem/util_windows.go
index f2c43025d4871..95616d34f6c61 100644
--- a/pkg/util/filesystem/util_windows.go
+++ b/pkg/util/filesystem/util_windows.go
@@ -46,20 +46,21 @@ const (
 // Note that due to the retry logic inside, it could take up to 4 seconds
 // to determine whether or not the file path supplied is a Unix domain socket
 func IsUnixDomainSocket(filePath string) (bool, error) {
-	// Due to the absence of golang support for os.ModeSocket in Windows (https://github.com/golang/go/issues/33357)
-	// we need to dial the file and check if we receive an error to determine if a file is Unix Domain Socket file.
-
 	// Note that querrying for the Reparse Points (https://docs.microsoft.com/en-us/windows/win32/fileio/reparse-points)
 	// for the file (using FSCTL_GET_REPARSE_POINT) and checking for reparse tag: reparseTagSocket
 	// does NOT work in 1809 if the socket file is created within a bind mounted directory by a container
 	// and the FSCTL is issued in the host by the kubelet.
 
 	// If the file does not exist, it cannot be a Unix domain socket.
-	if _, err := os.Stat(filePath); os.IsNotExist(err) {
+	if info, err := os.Stat(filePath); os.IsNotExist(err) {
 		return false, fmt.Errorf("File %s not found. Err: %v", filePath, err)
+	} else if err == nil && info.Mode()&os.ModeSocket != 0 { // Use os.ModeSocket (introduced in Go 1.23 on Windows)
+		klog.V(6).InfoS("File identified as a Unix domain socket", "filePath", filePath)
+		return true, nil
 	}
-
 	klog.V(6).InfoS("Function IsUnixDomainSocket starts", "filePath", filePath)
+	// Due to the absence of golang support for os.ModeSocket in Windows (https://github.com/golang/go/issues/33357)
+	// we need to dial the file and check if we receive an error to determine if a file is Unix Domain Socket file.
 	// As detailed in https://github.com/kubernetes/kubernetes/issues/104584 we cannot rely
 	// on the Unix Domain socket working on the very first try, hence the potential need to
 	// dial multiple times
diff --git a/pkg/volume/util/hostutil/hostutil_windows.go b/pkg/volume/util/hostutil/hostutil_windows.go
index 27bc8b212b92f..b702d1e7e9bce 100644
--- a/pkg/volume/util/hostutil/hostutil_windows.go
+++ b/pkg/volume/util/hostutil/hostutil_windows.go
@@ -29,7 +29,6 @@ import (
 
 	"golang.org/x/sys/windows"
 	"k8s.io/klog/v2"
-	"k8s.io/kubernetes/pkg/util/filesystem"
 	"k8s.io/mount-utils"
 	utilpath "k8s.io/utils/path"
 )
@@ -103,14 +102,6 @@ func isSystemCannotAccessErr(err error) bool {
 func (hu *(HostUtil)) GetFileType(pathname string) (FileType, error) {
 	filetype, err := getFileType(pathname)
 
-	// 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 err == errUnknownFileType || isSystemCannotAccessErr(err) {
-		if isSocket, errSocket := filesystem.IsUnixDomainSocket(pathname); errSocket == nil && isSocket {
-			return FileTypeSocket, nil
-		}
-	}
-
 	return filetype, err
 }
 
diff --git a/staging/src/k8s.io/api/go.mod b/staging/src/k8s.io/api/go.mod
index 33507e2254a76..3d3c2ebe61da1 100644
--- a/staging/src/k8s.io/api/go.mod
+++ b/staging/src/k8s.io/api/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/gogo/protobuf v1.3.2
 	k8s.io/apimachinery v0.0.0
diff --git a/staging/src/k8s.io/apiextensions-apiserver/go.mod b/staging/src/k8s.io/apiextensions-apiserver/go.mod
index ae32a6e458c74..98ab38255c4f3 100644
--- a/staging/src/k8s.io/apiextensions-apiserver/go.mod
+++ b/staging/src/k8s.io/apiextensions-apiserver/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/emicklei/go-restful/v3 v3.11.0
 	github.com/fxamacker/cbor/v2 v2.7.0
diff --git a/staging/src/k8s.io/apimachinery/go.mod b/staging/src/k8s.io/apimachinery/go.mod
index f8ff1ba4da5d9..4844461b6a1cf 100644
--- a/staging/src/k8s.io/apimachinery/go.mod
+++ b/staging/src/k8s.io/apimachinery/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5
 	github.com/davecgh/go-spew v1.1.1
diff --git a/staging/src/k8s.io/apiserver/go.mod b/staging/src/k8s.io/apiserver/go.mod
index 4720b7d96d0ca..8cdf89fb46971 100644
--- a/staging/src/k8s.io/apiserver/go.mod
+++ b/staging/src/k8s.io/apiserver/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/blang/semver/v4 v4.0.0
 	github.com/coreos/go-oidc v2.3.0+incompatible
diff --git a/staging/src/k8s.io/cli-runtime/go.mod b/staging/src/k8s.io/cli-runtime/go.mod
index 4e7645656ba03..2ff4e94e0b41f 100644
--- a/staging/src/k8s.io/cli-runtime/go.mod
+++ b/staging/src/k8s.io/cli-runtime/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/google/gnostic-models v0.6.9
 	github.com/google/go-cmp v0.6.0
diff --git a/staging/src/k8s.io/client-go/go.mod b/staging/src/k8s.io/client-go/go.mod
index c46cc54fd177d..3fd360ccc4046 100644
--- a/staging/src/k8s.io/client-go/go.mod
+++ b/staging/src/k8s.io/client-go/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/go-logr/logr v1.4.2
 	github.com/gogo/protobuf v1.3.2
diff --git a/staging/src/k8s.io/cloud-provider/go.mod b/staging/src/k8s.io/cloud-provider/go.mod
index f74e34ca6edab..d2371407f8196 100644
--- a/staging/src/k8s.io/cloud-provider/go.mod
+++ b/staging/src/k8s.io/cloud-provider/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/google/go-cmp v0.6.0
 	github.com/spf13/cobra v1.8.1
diff --git a/staging/src/k8s.io/cluster-bootstrap/go.mod b/staging/src/k8s.io/cluster-bootstrap/go.mod
index d345a6775fc76..0ce0d3d3e4f0f 100644
--- a/staging/src/k8s.io/cluster-bootstrap/go.mod
+++ b/staging/src/k8s.io/cluster-bootstrap/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/stretchr/testify v1.9.0
 	gopkg.in/go-jose/go-jose.v2 v2.6.3
diff --git a/staging/src/k8s.io/code-generator/go.mod b/staging/src/k8s.io/code-generator/go.mod
index 2ae0e85c8023d..55c92ba304ba1 100644
--- a/staging/src/k8s.io/code-generator/go.mod
+++ b/staging/src/k8s.io/code-generator/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/gogo/protobuf v1.3.2
 	github.com/google/gnostic-models v0.6.9
diff --git a/staging/src/k8s.io/component-base/go.mod b/staging/src/k8s.io/component-base/go.mod
index 41551214ff3bd..552da58589686 100644
--- a/staging/src/k8s.io/component-base/go.mod
+++ b/staging/src/k8s.io/component-base/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/blang/semver/v4 v4.0.0
 	github.com/go-logr/logr v1.4.2
diff --git a/staging/src/k8s.io/component-helpers/go.mod b/staging/src/k8s.io/component-helpers/go.mod
index 335011754203e..62c7e3efd15e2 100644
--- a/staging/src/k8s.io/component-helpers/go.mod
+++ b/staging/src/k8s.io/component-helpers/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/google/go-cmp v0.6.0
 	github.com/stretchr/testify v1.9.0
diff --git a/staging/src/k8s.io/controller-manager/go.mod b/staging/src/k8s.io/controller-manager/go.mod
index 3d95cd4137967..51ec126b03a11 100644
--- a/staging/src/k8s.io/controller-manager/go.mod
+++ b/staging/src/k8s.io/controller-manager/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/spf13/pflag v1.0.5
 	github.com/stretchr/testify v1.9.0
diff --git a/staging/src/k8s.io/cri-api/go.mod b/staging/src/k8s.io/cri-api/go.mod
index 371a5493f84b4..482112d74650e 100644
--- a/staging/src/k8s.io/cri-api/go.mod
+++ b/staging/src/k8s.io/cri-api/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/gogo/protobuf v1.3.2
 	github.com/stretchr/testify v1.9.0
diff --git a/staging/src/k8s.io/cri-client/go.mod b/staging/src/k8s.io/cri-client/go.mod
index 86b8907af2bbc..9f6ae88bcdb34 100644
--- a/staging/src/k8s.io/cri-client/go.mod
+++ b/staging/src/k8s.io/cri-client/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/Microsoft/go-winio v0.6.2
 	github.com/fsnotify/fsnotify v1.7.0
diff --git a/staging/src/k8s.io/csi-translation-lib/go.mod b/staging/src/k8s.io/csi-translation-lib/go.mod
index 16d167c3e4cd9..7341614f35cc3 100644
--- a/staging/src/k8s.io/csi-translation-lib/go.mod
+++ b/staging/src/k8s.io/csi-translation-lib/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/stretchr/testify v1.9.0
 	k8s.io/api v0.0.0
diff --git a/staging/src/k8s.io/dynamic-resource-allocation/go.mod b/staging/src/k8s.io/dynamic-resource-allocation/go.mod
index b3cc6b79642de..983a7f5e611be 100644
--- a/staging/src/k8s.io/dynamic-resource-allocation/go.mod
+++ b/staging/src/k8s.io/dynamic-resource-allocation/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/blang/semver/v4 v4.0.0
 	github.com/google/cel-go v0.23.2
diff --git a/staging/src/k8s.io/endpointslice/go.mod b/staging/src/k8s.io/endpointslice/go.mod
index 7fb7543e0a138..4b587d3290fcd 100644
--- a/staging/src/k8s.io/endpointslice/go.mod
+++ b/staging/src/k8s.io/endpointslice/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/google/go-cmp v0.6.0
 	github.com/stretchr/testify v1.9.0
diff --git a/staging/src/k8s.io/externaljwt/go.mod b/staging/src/k8s.io/externaljwt/go.mod
index 2186a237b4983..91306108b01d2 100644
--- a/staging/src/k8s.io/externaljwt/go.mod
+++ b/staging/src/k8s.io/externaljwt/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/gogo/protobuf v1.3.2
 	google.golang.org/grpc v1.65.0
diff --git a/staging/src/k8s.io/kms/go.mod b/staging/src/k8s.io/kms/go.mod
index 90e64c75a815a..f0a397ebaf1c2 100644
--- a/staging/src/k8s.io/kms/go.mod
+++ b/staging/src/k8s.io/kms/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/gogo/protobuf v1.3.2
 	google.golang.org/grpc v1.65.0
diff --git a/staging/src/k8s.io/kube-aggregator/go.mod b/staging/src/k8s.io/kube-aggregator/go.mod
index 0a4722eef7338..212747adeac28 100644
--- a/staging/src/k8s.io/kube-aggregator/go.mod
+++ b/staging/src/k8s.io/kube-aggregator/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/emicklei/go-restful/v3 v3.11.0
 	github.com/gogo/protobuf v1.3.2
diff --git a/staging/src/k8s.io/kube-controller-manager/go.mod b/staging/src/k8s.io/kube-controller-manager/go.mod
index 61f4ddad9a614..d9eb7eca352cb 100644
--- a/staging/src/k8s.io/kube-controller-manager/go.mod
+++ b/staging/src/k8s.io/kube-controller-manager/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	k8s.io/apimachinery v0.0.0
 	k8s.io/cloud-provider v0.0.0
diff --git a/staging/src/k8s.io/kube-proxy/go.mod b/staging/src/k8s.io/kube-proxy/go.mod
index 90fc824a18df7..cf3f5a4e97a37 100644
--- a/staging/src/k8s.io/kube-proxy/go.mod
+++ b/staging/src/k8s.io/kube-proxy/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	k8s.io/apimachinery v0.0.0
 	k8s.io/component-base v0.0.0
diff --git a/staging/src/k8s.io/kube-scheduler/go.mod b/staging/src/k8s.io/kube-scheduler/go.mod
index 2b511d0ce036b..ad3894751e057 100644
--- a/staging/src/k8s.io/kube-scheduler/go.mod
+++ b/staging/src/k8s.io/kube-scheduler/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/google/go-cmp v0.6.0
 	k8s.io/api v0.0.0
diff --git a/staging/src/k8s.io/kubectl/go.mod b/staging/src/k8s.io/kubectl/go.mod
index 3794c7f579560..698c185731141 100644
--- a/staging/src/k8s.io/kubectl/go.mod
+++ b/staging/src/k8s.io/kubectl/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/MakeNowJust/heredoc v1.0.0
 	github.com/chai2010/gettext-go v1.0.2
diff --git a/staging/src/k8s.io/kubelet/go.mod b/staging/src/k8s.io/kubelet/go.mod
index b42cd44fdabf0..2f48d19d5d766 100644
--- a/staging/src/k8s.io/kubelet/go.mod
+++ b/staging/src/k8s.io/kubelet/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/emicklei/go-restful/v3 v3.11.0
 	github.com/gogo/protobuf v1.3.2
diff --git a/staging/src/k8s.io/metrics/go.mod b/staging/src/k8s.io/metrics/go.mod
index a36935c47c7f6..3d8c1bdf7ad3c 100644
--- a/staging/src/k8s.io/metrics/go.mod
+++ b/staging/src/k8s.io/metrics/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/gogo/protobuf v1.3.2
 	github.com/stretchr/testify v1.9.0
diff --git a/staging/src/k8s.io/mount-utils/go.mod b/staging/src/k8s.io/mount-utils/go.mod
index b7281be9ace62..d75fabacc686a 100644
--- a/staging/src/k8s.io/mount-utils/go.mod
+++ b/staging/src/k8s.io/mount-utils/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/moby/sys/mountinfo v0.7.2
 	github.com/stretchr/testify v1.9.0
diff --git a/staging/src/k8s.io/pod-security-admission/go.mod b/staging/src/k8s.io/pod-security-admission/go.mod
index f485017a2997e..616130e560958 100644
--- a/staging/src/k8s.io/pod-security-admission/go.mod
+++ b/staging/src/k8s.io/pod-security-admission/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/blang/semver/v4 v4.0.0
 	github.com/google/go-cmp v0.6.0
diff --git a/staging/src/k8s.io/sample-apiserver/go.mod b/staging/src/k8s.io/sample-apiserver/go.mod
index 3ab438a526aab..d8a6b2b998091 100644
--- a/staging/src/k8s.io/sample-apiserver/go.mod
+++ b/staging/src/k8s.io/sample-apiserver/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/google/gofuzz v1.2.0
 	github.com/spf13/cobra v1.8.1
diff --git a/staging/src/k8s.io/sample-cli-plugin/go.mod b/staging/src/k8s.io/sample-cli-plugin/go.mod
index ca6c21ab8b3bd..c048d7f01f787 100644
--- a/staging/src/k8s.io/sample-cli-plugin/go.mod
+++ b/staging/src/k8s.io/sample-cli-plugin/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	github.com/spf13/cobra v1.8.1
 	github.com/spf13/pflag v1.0.5
diff --git a/staging/src/k8s.io/sample-controller/go.mod b/staging/src/k8s.io/sample-controller/go.mod
index 9d372560d75b4..7a6bc57ccead4 100644
--- a/staging/src/k8s.io/sample-controller/go.mod
+++ b/staging/src/k8s.io/sample-controller/go.mod
@@ -6,8 +6,6 @@ go 1.23.0
 
 godebug default=go1.23
 
-godebug winsymlink=0
-
 require (
 	golang.org/x/time v0.7.0
 	k8s.io/api v0.0.0


Test patch:
diff --git a/test/images/agnhost/mounttest/mt_utils_windows.go b/test/images/agnhost/mounttest/mt_utils_windows.go
index 2901c456e4860..c533048bb4a37 100644
--- a/test/images/agnhost/mounttest/mt_utils_windows.go
+++ b/test/images/agnhost/mounttest/mt_utils_windows.go
@@ -77,12 +77,15 @@ func getFilePerm(path string) (os.FileMode, error) {
 	// NOTE(claudiub): Symlinks have different permissions which might not match the target's.
 	// We want to evaluate the permissions of the target's not the symlink's.
 	info, err := os.Lstat(path)
-	if err == nil && info.Mode()&os.ModeSymlink != 0 {
-		evaluated, err := filepath.EvalSymlinks(path)
-		if err != nil {
-			return 0, err
+	if err == nil {
+		// go1.23 behavior change: https://github.com/golang/go/issues/63703#issuecomment-2535941458
+		if info.Mode()&os.ModeSymlink != 0 || info.Mode()&os.ModeIrregular != 0 {
+			evaluated, err := filepath.EvalSymlinks(path)
+			if err != nil {
+				return 0, err
+			}
+			path = evaluated
 		}
-		path = evaluated
 	}
 
 	cmd := exec.Command("powershell.exe", "-NonInteractive", "./filePermissions.ps1",