From 57d76df09a5e47e6448f24a15cc3a8cace09b89b Mon Sep 17 00:00:00 2001 From: Shivanjan Chakravorty Date: Wed, 23 Aug 2023 19:52:26 -0600 Subject: [PATCH] fix: don't default to sharedv4/shared for RWX Volumes if proxy spec is set Signed-off-by: Shivanjan Chakravorty --- csi/controller.go | 5 +++++ csi/controller_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/csi/controller.go b/csi/controller.go index dabae20ad..17f9dae77 100644 --- a/csi/controller.go +++ b/csi/controller.go @@ -800,6 +800,11 @@ func resolveSharedSpec(spec *api.VolumeSpec, req *csi.CreateVolumeRequest) (*api return spec, nil } + // don't default to sharedv4/shared for RWX Volumes if proxy spec is set + if spec.ProxySpec != nil { + return spec, nil + } + var shared bool for _, cap := range req.GetVolumeCapabilities() { mode := cap.GetAccessMode().GetMode() diff --git a/csi/controller_test.go b/csi/controller_test.go index 483ceaabe..a6f4386cd 100644 --- a/csi/controller_test.go +++ b/csi/controller_test.go @@ -3289,6 +3289,30 @@ func TestResolveSpecFromCSI(t *testing.T) { }, }, }, + { + name: "Should not set shared flag to true for RWX Volumes if proxy spec is set", + req: &csi.CreateVolumeRequest{ + VolumeCapabilities: []*csi.VolumeCapability{ + { + AccessMode: &csi.VolumeCapability_AccessMode{ + Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER, + }, + }, + }, + }, + existingSpec: &api.VolumeSpec{ + ProxySpec: &api.ProxySpec{ + ProxyProtocol: api.ProxyProtocol_PROXY_PROTOCOL_NFS, + }, + }, + + expectedSpec: &api.VolumeSpec{ + Shared: false, + ProxySpec: &api.ProxySpec{ + ProxyProtocol: api.ProxyProtocol_PROXY_PROTOCOL_NFS, + }, + }, + }, } for _, tc := range tt {