Merge pull request #127100 from jsturtevant/automated-cherry-pick-of-#126976-upstream-release-1.31

Automated cherry pick of #126976: Revert "fix: handle socket file detection on Windows"
This commit is contained in:
Kubernetes Prow Robot 2024-09-04 09:28:16 +01:00 committed by GitHub
commit f67b92227c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -203,12 +203,15 @@ func (m *ManagerImpl) CleanupPluginDirectory(dir string) error {
if filePath == m.checkpointFile() {
continue
}
stat, err := os.Stat(filePath)
// 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)
if err != nil {
klog.ErrorS(err, "Failed to stat file", "path", filePath)
continue
}
if stat.IsDir() || stat.Mode()&os.ModeSocket == 0 {
if stat.IsDir() {
continue
}
err = os.RemoveAll(filePath)