Skip to content

Commit

Permalink
fix: handle socket file detection on Windows
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fakecore authored and hungnguyen243 committed Aug 16, 2024
1 parent bc86d9f commit b1edee1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/kubelet/cm/devicemanager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,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)
Expand Down

0 comments on commit b1edee1

Please sign in to comment.