Skip to content

Commit

Permalink
iscsi: capture/log iscsi disconnect error and call safe removal
Browse files Browse the repository at this point in the history
At present while iscsi target disconnect is attempted, if there is
an error its ignored. This patch fetches the error if any and also
log it for further actions. Also to avoid accidental deletion of
user data we go with safe path of os.remove()

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
  • Loading branch information
humblec committed Apr 28, 2021
1 parent 608a1bd commit 59fc287
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/iscsi/iscsi.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func getISCSIInfo(req *csi.NodePublishVolumeRequest) (*iscsiDisk, error) {
}

for _, portal := range portals {
bkportal = append(bkportal, portalMounter(string(portal)))
bkportal = append(bkportal, portalMounter(portal))
}

iface := req.GetVolumeContext()["iscsiInterface"]
Expand Down
7 changes: 4 additions & 3 deletions pkg/iscsi/iscsi_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ func (util *ISCSIUtil) DetachDisk(c iscsiDiskUnmounter, targetPath string) error
return err
}

iscsi_lib.Disconnect(connector.TargetIqn, connector.TargetPortals)

if err := os.RemoveAll(targetPath); err != nil {
if disConnectErr := iscsi_lib.Disconnect(connector.TargetIqn, connector.TargetPortals); disConnectErr != nil {
klog.Warningf("Warning: Disconnect failed for IQN: %v", connector.TargetIqn)
}
if err := os.Remove(targetPath); err != nil {
klog.Errorf("iscsi: failed to remove mount path Error: %v", err)
return err
}
Expand Down

0 comments on commit 59fc287

Please sign in to comment.