mirror of https://github.com/k3s-io/k3s
Don't fail if iface is being used by iSCSI session
parent
6de09f69cb
commit
d60d7e905f
|
@ -27,6 +27,7 @@ go_library(
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
"//staging/src/k8s.io/apiserver/pkg/util/feature:go_default_library",
|
||||||
"//vendor/k8s.io/klog: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/keymutex:go_default_library",
|
||||||
"//vendor/k8s.io/utils/strings:go_default_library",
|
"//vendor/k8s.io/utils/strings:go_default_library",
|
||||||
],
|
],
|
||||||
|
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"k8s.io/kubernetes/pkg/util/mount"
|
"k8s.io/kubernetes/pkg/util/mount"
|
||||||
"k8s.io/kubernetes/pkg/volume"
|
"k8s.io/kubernetes/pkg/volume"
|
||||||
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
volumeutil "k8s.io/kubernetes/pkg/volume/util"
|
||||||
|
utilexec "k8s.io/utils/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -51,6 +52,10 @@ const (
|
||||||
|
|
||||||
// How many seconds to wait for a multipath device if at least two paths are available.
|
// How many seconds to wait for a multipath device if at least two paths are available.
|
||||||
multipathDeviceTimeout = 10
|
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 (
|
var (
|
||||||
|
@ -872,9 +877,14 @@ func cloneIface(b iscsiDiskMounter, newIface string) error {
|
||||||
// create new iface
|
// create new iface
|
||||||
out, err = b.exec.Run("iscsiadm", "-m", "iface", "-I", newIface, "-o", "new")
|
out, err = b.exec.Run("iscsiadm", "-m", "iface", "-I", newIface, "-o", "new")
|
||||||
if err != nil {
|
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)
|
lastErr = fmt.Errorf("iscsi: failed to create new iface: %s (%v)", string(out), err)
|
||||||
return lastErr
|
return lastErr
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// update new iface records
|
// update new iface records
|
||||||
for key, val := range params {
|
for key, val := range params {
|
||||||
_, err = b.exec.Run("iscsiadm", "-m", "iface", "-I", newIface, "-o", "update", "-n", key, "-v", val)
|
_, err = b.exec.Run("iscsiadm", "-m", "iface", "-I", newIface, "-o", "update", "-n", key, "-v", val)
|
||||||
|
|
Loading…
Reference in New Issue