Skip to content

Commit b9f6013

Browse files
fix: handle socket file detection on Windows
Cherry-picked kubernetes@4060ee6 Update socket file detection logic to use os.Stat as per upstream Go fix for golang/go#33357. This resolves the issue where socket files could not be properly identified on Windows systems.
1 parent dfc8b27 commit b9f6013

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

pkg/kubelet/cm/devicemanager/manager.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,12 @@ func (m *ManagerImpl) CleanupPluginDirectory(dir string) error {
202202
if filePath == m.checkpointFile() {
203203
continue
204204
}
205-
// TODO: Until the bug - https://github.com/golang/go/issues/33357 is fixed, os.stat wouldn't return the
206-
// right mode(socket) on windows. Hence deleting the file, without checking whether
207-
// its a socket, on windows.
208-
stat, err := os.Lstat(filePath)
205+
stat, err := os.Stat(filePath)
209206
if err != nil {
210207
klog.ErrorS(err, "Failed to stat file", "path", filePath)
211208
continue
212209
}
213-
if stat.IsDir() {
210+
if stat.IsDir() || stat.Mode()&os.ModeSocket == 0 {
214211
continue
215212
}
216213
err = os.RemoveAll(filePath)

0 commit comments

Comments
 (0)