From 69a2deea9c4b7aafb6644c86d4fe22f2990a108d Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 20 Dec 2017 15:37:22 -0600 Subject: [PATCH 1/2] iscsi: set node.startup to manual If the default iSCSI node.startup is set to automatic, if there is a node failure, any pods on that node will get rescheduled to another node. If the failed node is later brought back up it will then try to log back in to any iSCSI sessions it had prior to the failure, which may no longer exist or may be now in-use by the other nodes. It appears most platforms keep the open-iscsi default of node.startup-automatic. But in case this system-wide setting has been changed, and just to be explicit, this sets node.startup values for kubernetes controlled volumes to manual. Closes issue #21305 --- pkg/volume/iscsi/iscsi_util.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/volume/iscsi/iscsi_util.go b/pkg/volume/iscsi/iscsi_util.go index a72dace7735..6c6d03c0034 100644 --- a/pkg/volume/iscsi/iscsi_util.go +++ b/pkg/volume/iscsi/iscsi_util.go @@ -279,6 +279,12 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) { lastErr = fmt.Errorf("iscsi: failed to attach disk: Error: %s (%v)", string(out), err) continue } + // in case of node failure/restart, explicitly set to manual login so it doesn't hang on boot + out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "node.startup", "-v", "manual") + if err != nil { + // don't fail if we can't set startup mode, but log warning so there is a clue + glog.Warningf("Warning: Failed to set iSCSI login mode to manual. Error: %v", err) + } if exist := waitForPathToExist(&devicePath, 10, iscsiTransport); !exist { glog.Errorf("Could not attach disk: Timeout after 10s") // update last error From 9f97d61de4e9a188f8ef2c58d6e1786c6793225e Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Wed, 20 Dec 2017 23:48:15 -0600 Subject: [PATCH 2/2] Fixed space/tab indentation Some lines had spaces for indentation instead of tabs. --- pkg/volume/iscsi/iscsi_util.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/volume/iscsi/iscsi_util.go b/pkg/volume/iscsi/iscsi_util.go index 6c6d03c0034..12e8430d85e 100644 --- a/pkg/volume/iscsi/iscsi_util.go +++ b/pkg/volume/iscsi/iscsi_util.go @@ -279,8 +279,8 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) { lastErr = fmt.Errorf("iscsi: failed to attach disk: Error: %s (%v)", string(out), err) continue } - // in case of node failure/restart, explicitly set to manual login so it doesn't hang on boot - out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "node.startup", "-v", "manual") + // in case of node failure/restart, explicitly set to manual login so it doesn't hang on boot + out, err = b.exec.Run("iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-o", "update", "node.startup", "-v", "manual") if err != nil { // don't fail if we can't set startup mode, but log warning so there is a clue glog.Warningf("Warning: Failed to set iSCSI login mode to manual. Error: %v", err)