From cd53c23d500d555bf53ba423ea4081a9348e19ca Mon Sep 17 00:00:00 2001 From: Lukas Metzner Date: Wed, 2 Oct 2024 08:47:55 +0200 Subject: [PATCH] feat: Support SINGLE_NODE_MULTI_WRITER capability (#725) See #327 --- internal/driver/controller_test.go | 53 +++++++++++++++++++++--------- internal/driver/helper.go | 2 ++ test/e2e/kubernetes/Makefile | 1 - 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/internal/driver/controller_test.go b/internal/driver/controller_test.go index d8e2b0e2..f432f514 100644 --- a/internal/driver/controller_test.go +++ b/internal/driver/controller_test.go @@ -741,25 +741,48 @@ func TestControllerServiceValidateVolumeCapabilities(t *testing.T) { return &csi.Volume{ID: id}, nil } - req := &proto.ValidateVolumeCapabilitiesRequest{ - VolumeId: "1", - VolumeCapabilities: []*proto.VolumeCapability{ - { - AccessMode: &proto.VolumeCapability_AccessMode{ - Mode: proto.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + testCases := []struct { + Name string + Req *proto.ValidateVolumeCapabilitiesRequest + Code codes.Code + }{ + { + Name: "SINGLE_NODE_WRITER", + Req: &proto.ValidateVolumeCapabilitiesRequest{ + VolumeId: "1", + VolumeCapabilities: []*proto.VolumeCapability{ + { + AccessMode: &proto.VolumeCapability_AccessMode{ + Mode: proto.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, + }, + }, }, }, + Code: codes.OK, + }, + { + Name: "SINGLE_NODE_MULTI_WRITER", + Req: &proto.ValidateVolumeCapabilitiesRequest{ + VolumeId: "1", + VolumeCapabilities: []*proto.VolumeCapability{ + { + AccessMode: &proto.VolumeCapability_AccessMode{ + Mode: proto.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER, + }, + }, + }, + }, + Code: codes.OK, }, } - resp, err := env.service.ValidateVolumeCapabilities(env.ctx, req) - if err != nil { - t.Fatal(err) - } - if resp.Confirmed == nil { - t.Fatal("expected confirmation") - } - if len(resp.Confirmed.VolumeCapabilities) != 1 { - t.Errorf("unexpected confirmed capabilities: %v", resp.Confirmed.VolumeCapabilities) + + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + _, err := env.service.ValidateVolumeCapabilities(env.ctx, testCase.Req) + if status.Code(err) != testCase.Code { + t.Fatalf("unexpected error: %v", err) + } + }) } } diff --git a/internal/driver/helper.go b/internal/driver/helper.go index 3e8bfa13..01a4c457 100644 --- a/internal/driver/helper.go +++ b/internal/driver/helper.go @@ -52,6 +52,8 @@ func isCapabilitySupported(cap *proto.VolumeCapability) bool { switch cap.AccessMode.Mode { case proto.VolumeCapability_AccessMode_SINGLE_NODE_WRITER: return true + case proto.VolumeCapability_AccessMode_SINGLE_NODE_MULTI_WRITER: + return true default: return false } diff --git a/test/e2e/kubernetes/Makefile b/test/e2e/kubernetes/Makefile index 58479eb3..608d2ccd 100644 --- a/test/e2e/kubernetes/Makefile +++ b/test/e2e/kubernetes/Makefile @@ -25,7 +25,6 @@ parallel: bin serial: bin $(GINKGO) $(GINKGO_ARGS) \ -focus='External.Storage.*(\[Feature:|\[Serial\])' \ - -skip='\[Feature:SELinuxMountReadWriteOncePod\]' \ $(E2E) -- $(E2E_ARGS) test: parallel serial