Commit fcf183dc authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #46239 from mtanino/issue/45394

Automatic merge from submit-queue Log out from multiple target portals when using iscsi storage plugin **What this PR does / why we need it**: 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 mount points for all TPs, and then log out from all TPs when a pod is destroyed. If a TP is referred from another pods, the connection will be remained as usual. **Which issue this PR fixes** fixes #45394 **Special notes for your reviewer**: **Release note**: ``` NONE ```
parents 3093936a aebaee39
...@@ -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