Skip to content

Commit 32d798c

Browse files
author
Elliot Li
committed
Handle case that multipath device is no longer available in sysfs
Change-Id: Ib48a47bdb270aebcb169b605064189c91b49c055
1 parent 6078a2a commit 32d798c

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

utils/iscsi.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/binary"
88
"encoding/hex"
99
"fmt"
10+
"io/fs"
1011
"os"
1112
"os/exec"
1213
"regexp"
@@ -478,8 +479,12 @@ func (h *IscsiReconcileHelper) GetMultipathDeviceDisks(ctx context.Context, mult
478479
diskPath := chrootPathPrefix + fmt.Sprintf("/sys/block/%s/slaves/", multipathDevice)
479480
diskDirs, err := os.ReadDir(diskPath)
480481
if err != nil {
481-
Logc(ctx).WithError(err).Errorf("Could not read %s", diskDirs)
482-
return nil, fmt.Errorf("failed to identify multipath device disks; unable to read '%s'", diskDirs)
482+
if errors.Is(err, fs.ErrNotExist) {
483+
Logc(ctx).Warningf("multipath device directory %s does not exist, device is already gone?", diskDirs)
484+
return nil, nil
485+
}
486+
Logc(ctx).WithError(err).Errorf("Could not read %s", diskPath)
487+
return nil, fmt.Errorf("failed to identify multipath device disks; unable to read %q :%w", diskPath, err)
483488
}
484489

485490
for _, diskDir := range diskDirs {

0 commit comments

Comments
 (0)