Don't fail if iface is being used by iSCSI session

pull/564/head
Fabio Bertinatto 2019-02-22 15:49:44 +01:00
parent 6de09f69cb
commit d60d7e905f
2 changed files with 13 additions and 2 deletions

View File

@ -27,6 +27,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
"//vendor/k8s.io/utils/exec:go_default_library",
"//vendor/k8s.io/utils/keymutex:go_default_library",
"//vendor/k8s.io/utils/strings:go_default_library",
],

View File

@ -34,6 +34,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/volume"
volumeutil "k8s.io/kubernetes/pkg/volume/util"
utilexec "k8s.io/utils/exec"
)
const (
@ -51,6 +52,10 @@ const (
// How many seconds to wait for a multipath device if at least two paths are available.
multipathDeviceTimeout = 10
// 'iscsiadm' error code stating that a session is logged in
// See https://github.com/open-iscsi/open-iscsi/blob/7d121d12ad6ba7783308c25ffd338a9fa0cc402b/include/iscsi_err.h#L37-L38
iscsiadmErrorSessExists = 15
)
var (
@ -872,9 +877,14 @@ func cloneIface(b iscsiDiskMounter, newIface string) error {
// create new iface
out, err = b.exec.Run("iscsiadm", "-m", "iface", "-I", newIface, "-o", "new")
if err != nil {
exit, ok := err.(utilexec.ExitError)
if ok && exit.ExitStatus() == iscsiadmErrorSessExists {
klog.Infof("iscsi: there is a session already logged in with iface %s", newIface)
} else {
lastErr = fmt.Errorf("iscsi: failed to create new iface: %s (%v)", string(out), err)
return lastErr
}
}
// update new iface records
for key, val := range params {
_, err = b.exec.Run("iscsiadm", "-m", "iface", "-I", newIface, "-o", "update", "-n", key, "-v", val)