Skip to content

Commit cbb0e03

Browse files
committed
Remove cross validation of access modes, multiple access modes can be specified that represent all the capabilities of the volume
1 parent e1c01f8 commit cbb0e03

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

pkg/gce-pd-csi-driver/utils.go

-25
Original file line numberDiff line numberDiff line change
@@ -72,31 +72,6 @@ func validateVolumeCapabilities(vcs []*csi.VolumeCapability) error {
7272
return err
7373
}
7474
}
75-
if err := crossValidateAccessModes(vcs); err != nil {
76-
return err
77-
}
78-
return nil
79-
}
80-
81-
func crossValidateAccessModes(vcs []*csi.VolumeCapability) error {
82-
m := map[csi.VolumeCapability_AccessMode_Mode]bool{}
83-
84-
for _, vc := range vcs {
85-
m[vc.GetAccessMode().GetMode()] = true
86-
}
87-
88-
hasWriter := m[csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER]
89-
hasSingleReader := m[csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY]
90-
hasMultiReader := m[csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY]
91-
92-
if hasWriter && (hasSingleReader || hasMultiReader) {
93-
return fmt.Errorf("both SINGLE_NODE_WRITER and READER_ONLY access mode specified")
94-
}
95-
96-
if hasSingleReader && hasMultiReader {
97-
return fmt.Errorf("both SINGLE_NODE_READER_ONLY and MULTI_NODE_READY_ONLY specified")
98-
}
99-
10075
return nil
10176
}
10277

pkg/gce-pd-csi-driver/utils_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -140,20 +140,18 @@ func TestValidateVolumeCapabilities(t *testing.T) {
140140
expErr: true,
141141
},
142142
{
143-
name: "fail with reader + writer capabilities",
143+
name: "success with reader + writer capabilities",
144144
vc: []*csi.VolumeCapability{
145145
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY),
146146
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
147147
},
148-
expErr: true,
149148
},
150149
{
151-
name: "fail with different reader capabilities",
150+
name: "success with different reader capabilities",
152151
vc: []*csi.VolumeCapability{
153152
createVolumeCapability(csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY),
154153
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY),
155154
},
156-
expErr: true,
157155
},
158156
}
159157

0 commit comments

Comments
 (0)