From 976aefca1b264277bb63bd92bf3c9d73d24f5c72 Mon Sep 17 00:00:00 2001 From: andyzhangx Date: Mon, 23 Dec 2024 09:22:31 +0000 Subject: [PATCH] fix: adopt go1.23 behavior change in mount point parsing on Windows --- .../src/k8s.io/mount-utils/mount_windows.go | 31 +++---------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/staging/src/k8s.io/mount-utils/mount_windows.go b/staging/src/k8s.io/mount-utils/mount_windows.go index 9c8ad054f8a..682cb0f0114 100644 --- a/staging/src/k8s.io/mount-utils/mount_windows.go +++ b/staging/src/k8s.io/mount-utils/mount_windows.go @@ -242,6 +242,10 @@ func (mounter *Mounter) IsLikelyNotMountPoint(file string) (bool, error) { if stat.Mode()&os.ModeSymlink != 0 { return false, err } + // go1.23 behavior change: https://github.com/golang/go/issues/63703#issuecomment-2535941458 + if stat.Mode()&os.ModeIrregular != 0 { + return false, err + } return true, nil } @@ -329,30 +333,3 @@ func ListVolumesOnDisk(diskID string) (volumeIDs []string, err error) { volumeIds := strings.Split(strings.TrimSpace(string(output)), "\r\n") return volumeIds, nil } - -// getAllParentLinks walks all symbolic links and return all the parent targets recursively -func getAllParentLinks(path string) ([]string, error) { - const maxIter = 255 - links := []string{} - for { - links = append(links, path) - if len(links) > maxIter { - return links, fmt.Errorf("unexpected length of parent links: %v", links) - } - - fi, err := os.Lstat(path) - if err != nil { - return links, fmt.Errorf("Lstat: %v", err) - } - if fi.Mode()&os.ModeSymlink == 0 { - break - } - - path, err = os.Readlink(path) - if err != nil { - return links, fmt.Errorf("Readlink error: %v", err) - } - } - - return links, nil -}