sodafoundation / api

SODA Terra Project API module : is an open source implementation of SODA API connecting storage to platforms like Kubernetes, OpenStack, and VMware
Apache License 2.0
828 stars 316 forks source link

iscsi connector cannot detach #649

Open xxwjj opened 5 years ago

xxwjj commented 5 years ago

There is a logcal bug, that the logoutFalg == ''0'' will nerver be true, enven though I execute iscsi rescan comamnd: "iscsiadm -m session -R". It seems that the rescan command only refresh the new added lun, while could not refresh lun the which has already been removed in target side . so that the link in '/dev/disk/by-path' wouldn't be removed too. And in some linux system, such as Suse, it enven does not has this formatted link. So logout a session shouldn't depend on the link number.

root@opensds:~# ll /dev/disk/by-path/
total 0
drwxr-xr-x 2 root root 160 Apr  9 06:51 ./
drwxr-xr-x 5 root root 100 Mar 28 22:23 ../
lrwxrwxrwx 1 root root   9 Apr  9 06:51 ip-8.47.193.125:3260-iscsi-iqn.2006-08.com.huawei:oceanstor:210048435a227e94::20001:8.47.193.125-lun-1 -> ../../sdb·

https://github.com/opensds/opensds/blob/1961ff33ad03ffd110caddd411a6bc1d6cef916e/contrib/connector/iscsi/helper.go#L303

func disconnect(conn map[string]interface{}) error {
    iscsiCon, index, err := parseIscsiConnectInfo(conn)
    if err != nil {
        return err
    }
    portal := iscsiCon.TgtPortal[index]
    targetiqn := iscsiCon.TgtIQN[index]
    cmd := "ls /dev/disk/by-path/ |grep -w " + portal + "|grep -w " + targetiqn + "|wc -l |awk '{if($1>1) print 1; else print 0}'"
    logoutFlag, err := connector.ExecCmd("/bin/bash", "-c", cmd)
    if err != nil {
        log.Printf("Disconnect iscsi target failed, %v\n", err)
        return err
    }

    logoutFlag = strings.Replace(logoutFlag, "\n", "", -1)
    if logoutFlag == "0" {
leonwanghui commented 5 years ago

@xxwjj Any update on this issue?

leonwanghui commented 5 years ago

@jackhaibo PTAL, thanks

skdwriting commented 5 years ago

@jackhaibo , could you please update?