mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
commit
8c1ffb59e3
@ -89,7 +89,7 @@ func updateISCSIDiscoverydb(b iscsiDiskMounter, tp string) error {
|
|||||||
}
|
}
|
||||||
out, err := execWithLog(b, "iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", "discovery.sendtargets.auth.authmethod", "-v", "CHAP")
|
out, err := execWithLog(b, "iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "update", "-n", "discovery.sendtargets.auth.authmethod", "-v", "CHAP")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("iscsi: failed to update discoverydb with CHAP, output: %v", string(out))
|
return fmt.Errorf("iscsi: failed to update discoverydb with CHAP, output: %v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range chapSt {
|
for _, k := range chapSt {
|
||||||
@ -112,7 +112,7 @@ func updateISCSINode(b iscsiDiskMounter, tp string) error {
|
|||||||
|
|
||||||
out, err := execWithLog(b, "iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "-o", "update", "-n", "node.session.auth.authmethod", "-v", "CHAP")
|
out, err := execWithLog(b, "iscsiadm", "-m", "node", "-p", tp, "-T", b.Iqn, "-I", b.Iface, "-o", "update", "-n", "node.session.auth.authmethod", "-v", "CHAP")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("iscsi: failed to update node with CHAP, output: %v", string(out))
|
return fmt.Errorf("iscsi: failed to update node with CHAP, output: %v", out)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, k := range chapSess {
|
for _, k := range chapSess {
|
||||||
@ -257,7 +257,7 @@ func waitForMultiPathToExist(devicePaths []string, maxRetries int, deviceUtil vo
|
|||||||
|
|
||||||
for i := 0; i < maxRetries; i++ {
|
for i := 0; i < maxRetries; i++ {
|
||||||
for _, path := range devicePaths {
|
for _, path := range devicePaths {
|
||||||
// There shouldnt be any empty device paths. However adding this check
|
// There shouldn't be any empty device paths. However adding this check
|
||||||
// for safer side to avoid the possibility of an empty entry.
|
// for safer side to avoid the possibility of an empty entry.
|
||||||
if path == "" {
|
if path == "" {
|
||||||
continue
|
continue
|
||||||
@ -284,11 +284,11 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
|
|||||||
|
|
||||||
out, err := execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.InitIface, "-o", "show")
|
out, err := execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.InitIface, "-o", "show")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("iscsi: could not read iface %s error: %s", b.InitIface, string(out))
|
klog.Errorf("iscsi: could not read iface %s error: %s", b.InitIface, out)
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
iscsiTransport = extractTransportname(string(out))
|
iscsiTransport = extractTransportname(out)
|
||||||
|
|
||||||
bkpPortal := b.Portals
|
bkpPortal := b.Portals
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// delete discoverydb record
|
// delete discoverydb record
|
||||||
execWithLog(b, "iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "delete")
|
execWithLog(b, "iscsiadm", "-m", "discoverydb", "-t", "sendtargets", "-p", tp, "-I", b.Iface, "-o", "delete")
|
||||||
lastErr = fmt.Errorf("iscsi: failed to sendtargets to portal %s output: %s, err %v", tp, string(out), err)
|
lastErr = fmt.Errorf("iscsi: failed to sendtargets to portal %s output: %s, err %v", tp, out, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ func (util *ISCSIUtil) AttachDisk(b iscsiDiskMounter) (string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
// delete the node record from database
|
// delete the node record from database
|
||||||
execWithLog(b, "iscsiadm", "-m", "node", "-p", tp, "-I", b.Iface, "-T", b.Iqn, "-o", "delete")
|
execWithLog(b, "iscsiadm", "-m", "node", "-p", tp, "-I", b.Iface, "-T", b.Iqn, "-o", "delete")
|
||||||
lastErr = fmt.Errorf("iscsi: failed to attach disk: Error: %s (%v)", string(out), err)
|
lastErr = fmt.Errorf("iscsi: failed to attach disk: Error: %s (%v)", out, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -796,7 +796,7 @@ func extractDeviceAndPrefix(mntPath string) (string, string, error) {
|
|||||||
|
|
||||||
func extractIface(mntPath string) (string, bool) {
|
func extractIface(mntPath string) (string, bool) {
|
||||||
reOutput := ifaceRe.FindStringSubmatch(mntPath)
|
reOutput := ifaceRe.FindStringSubmatch(mntPath)
|
||||||
if reOutput != nil {
|
if reOutput != nil && len(reOutput) > 1 {
|
||||||
return reOutput[1], true
|
return reOutput[1], true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,13 +862,13 @@ func cloneIface(b iscsiDiskMounter) error {
|
|||||||
// get pre-configured iface records
|
// get pre-configured iface records
|
||||||
out, err := execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.InitIface, "-o", "show")
|
out, err := execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.InitIface, "-o", "show")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lastErr = fmt.Errorf("iscsi: failed to show iface records: %s (%v)", string(out), err)
|
lastErr = fmt.Errorf("iscsi: failed to show iface records: %s (%v)", out, err)
|
||||||
return lastErr
|
return lastErr
|
||||||
}
|
}
|
||||||
// parse obtained records
|
// parse obtained records
|
||||||
params, err := parseIscsiadmShow(string(out))
|
params, err := parseIscsiadmShow(out)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lastErr = fmt.Errorf("iscsi: failed to parse iface records: %s (%v)", string(out), err)
|
lastErr = fmt.Errorf("iscsi: failed to parse iface records: %s (%v)", out, err)
|
||||||
return lastErr
|
return lastErr
|
||||||
}
|
}
|
||||||
// update initiatorname
|
// update initiatorname
|
||||||
@ -880,7 +880,7 @@ func cloneIface(b iscsiDiskMounter) error {
|
|||||||
if ok && exit.ExitStatus() == iscsiadmErrorSessExists {
|
if ok && exit.ExitStatus() == iscsiadmErrorSessExists {
|
||||||
klog.Infof("iscsi: there is a session already logged in with iface %s", b.Iface)
|
klog.Infof("iscsi: there is a session already logged in with iface %s", b.Iface)
|
||||||
} else {
|
} 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)", out, err)
|
||||||
return lastErr
|
return lastErr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -889,7 +889,7 @@ func cloneIface(b iscsiDiskMounter) error {
|
|||||||
_, err = execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "update", "-n", key, "-v", val)
|
_, err = execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "update", "-n", key, "-v", val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "delete")
|
execWithLog(b, "iscsiadm", "-m", "iface", "-I", b.Iface, "-o", "delete")
|
||||||
lastErr = fmt.Errorf("iscsi: failed to update iface records: %s (%v). iface(%s) will be used", string(out), err, b.InitIface)
|
lastErr = fmt.Errorf("iscsi: failed to update iface records: %s (%v). iface(%s) will be used", out, err, b.InitIface)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -963,13 +963,13 @@ func ignoreExitCodes(err error, ignoredExitCodes ...int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func execWithLog(b iscsiDiskMounter, cmd string, args ...string) ([]byte, error) {
|
func execWithLog(b iscsiDiskMounter, cmd string, args ...string) (string, error) {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
out, err := b.exec.Run(cmd, args...)
|
out, err := b.exec.Run(cmd, args...)
|
||||||
if klog.V(5) {
|
if klog.V(5) {
|
||||||
d := time.Now().Sub(start)
|
d := time.Since(start)
|
||||||
klog.V(5).Infof("Executed %s %v in %v, err: %v", cmd, args, d, err)
|
klog.V(5).Infof("Executed %s %v in %v, err: %v", cmd, args, d, err)
|
||||||
klog.V(5).Infof("Output: %s", string(out))
|
klog.V(5).Infof("Output: %s", string(out))
|
||||||
}
|
}
|
||||||
return out, err
|
return string(out), err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user