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 {