From dc46f483b58a7f907a334856ff3b156b88e476b3 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 20 Feb 2019 17:17:01 +0100 Subject: [PATCH] Fix scanning of failed targets If a iSCSI target is down while a volume is attached, reading from /sys/class/iscsi_host/host415/device/session383/connection383:0/iscsi_connection/connection383:0/address fails with an error. Kubelet should assume that such target is not available / logged in and try to relogin. Eventually, if such error persists, it should continue mounting the volume if the other paths are healthy instead of failing whole WaitForAttach(). --- pkg/volume/util/device_util_linux.go | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/volume/util/device_util_linux.go b/pkg/volume/util/device_util_linux.go index 66e8564915..2ea29d0148 100644 --- a/pkg/volume/util/device_util_linux.go +++ b/pkg/volume/util/device_util_linux.go @@ -21,10 +21,11 @@ package util import ( "errors" "fmt" - "k8s.io/klog" "path" "strconv" "strings" + + "k8s.io/klog" ) // FindMultipathDeviceForDevice given a device name like /dev/sdx, find the devicemapper parent @@ -135,7 +136,8 @@ func (handler *deviceHandler) GetISCSIPortalHostMapForTarget(targetIqn string) ( targetNamePath := sessionPath + "/iscsi_session/" + sessionName + "/targetname" targetName, err := io.ReadFile(targetNamePath) if err != nil { - return nil, err + klog.Infof("Failed to process session %s, assuming this session is unavailable: %s", sessionName, err) + continue } // Ignore hosts that don't matchthe target we were looking for. @@ -147,7 +149,8 @@ func (handler *deviceHandler) GetISCSIPortalHostMapForTarget(targetIqn string) ( // for the iSCSI connection. dirs2, err := io.ReadDir(sessionPath) if err != nil { - return nil, err + klog.Infof("Failed to process session %s, assuming this session is unavailable: %s", sessionName, err) + continue } for _, dir2 := range dirs2 { // Skip over files that aren't the connection @@ -164,25 +167,29 @@ func (handler *deviceHandler) GetISCSIPortalHostMapForTarget(targetIqn string) ( addrPath := connectionPath + "/address" addr, err := io.ReadFile(addrPath) if err != nil { - return nil, err + klog.Infof("Failed to process connection %s, assuming this connection is unavailable: %s", dirName, err) + continue } portPath := connectionPath + "/port" port, err := io.ReadFile(portPath) if err != nil { - return nil, err + klog.Infof("Failed to process connection %s, assuming this connection is unavailable: %s", dirName, err) + continue } persistentAddrPath := connectionPath + "/persistent_address" persistentAddr, err := io.ReadFile(persistentAddrPath) if err != nil { - return nil, err + klog.Infof("Failed to process connection %s, assuming this connection is unavailable: %s", dirName, err) + continue } persistentPortPath := connectionPath + "/persistent_port" persistentPort, err := io.ReadFile(persistentPortPath) if err != nil { - return nil, err + klog.Infof("Failed to process connection %s, assuming this connection is unavailable: %s", dirName, err) + continue } // Add entries to the map for both the current and persistent portals