Commit aebaee39 authored by mtanino's avatar mtanino

Log out from multiple portals with iscsi storage plugin

When using iscsi storage with multiple target portal (TP) addresses and multipathing the volume manager logs on to the IQN for all portal addresses, but when a pod gets destroyed the volume manager only logs out for the primary TP and sessions for another TPs are always remained. This patch adds methods to store and load iscsi disk configrations, then uses the stored config at DetachDisk path. Fix #45394
parent 7043372d
...@@ -136,10 +136,10 @@ func (plugin *iscsiPlugin) newMounterInternal(spec *volume.Spec, podUID types.UI ...@@ -136,10 +136,10 @@ func (plugin *iscsiPlugin) newMounterInternal(spec *volume.Spec, podUID types.UI
iscsiDisk: &iscsiDisk{ iscsiDisk: &iscsiDisk{
podUID: podUID, podUID: podUID,
volName: spec.Name(), volName: spec.Name(),
portals: bkportal, Portals: bkportal,
iqn: iscsi.IQN, Iqn: iscsi.IQN,
lun: lun, lun: lun,
iface: iface, Iface: iface,
chap_discovery: iscsi.DiscoveryCHAPAuth, chap_discovery: iscsi.DiscoveryCHAPAuth,
chap_session: iscsi.SessionCHAPAuth, chap_session: iscsi.SessionCHAPAuth,
secret: secret, secret: secret,
...@@ -191,10 +191,10 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v ...@@ -191,10 +191,10 @@ func (plugin *iscsiPlugin) ConstructVolumeSpec(volumeName, mountPath string) (*v
type iscsiDisk struct { type iscsiDisk struct {
volName string volName string
podUID types.UID podUID types.UID
portals []string Portals []string
iqn string Iqn string
lun string lun string
iface string Iface string
chap_discovery bool chap_discovery bool
chap_session bool chap_session bool
secret map[string]string secret map[string]string
......
...@@ -19,6 +19,7 @@ package iscsi ...@@ -19,6 +19,7 @@ package iscsi
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"reflect"
"testing" "testing"
"k8s.io/kubernetes/pkg/util/mount" "k8s.io/kubernetes/pkg/util/mount"
...@@ -91,6 +92,15 @@ func TestExtractPortalAndIqn(t *testing.T) { ...@@ -91,6 +92,15 @@ func TestExtractPortalAndIqn(t *testing.T) {
} }
} }
func TestRemoveDuplicate(t *testing.T) {
dupPortals := []string{"127.0.0.1:3260", "127.0.0.1:3260", "127.0.0.100:3260"}
portals := removeDuplicate(dupPortals)
want := []string{"127.0.0.1:3260", "127.0.0.100:3260"}
if reflect.DeepEqual(portals, want) == false {
t.Errorf("removeDuplicate: want: %s, got: %s", want, portals)
}
}
func fakeOsStat(devicePath string) (fi os.FileInfo, err error) { func fakeOsStat(devicePath string) (fi os.FileInfo, err error) {
var cmd os.FileInfo var cmd os.FileInfo
return cmd, nil return cmd, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment