Skip to content

Remove cross validation of access modes, multiple access modes can be specified that represent all the capabilities of the volume #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions pkg/gce-pd-csi-driver/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,6 @@ func validateVolumeCapabilities(vcs []*csi.VolumeCapability) error {
return err
}
}
if err := crossValidateAccessModes(vcs); err != nil {
return err
}
return nil
}

func crossValidateAccessModes(vcs []*csi.VolumeCapability) error {
m := map[csi.VolumeCapability_AccessMode_Mode]bool{}

for _, vc := range vcs {
m[vc.GetAccessMode().GetMode()] = true
}

hasWriter := m[csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER]
hasSingleReader := m[csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY]
hasMultiReader := m[csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY]

if hasWriter && (hasSingleReader || hasMultiReader) {
return fmt.Errorf("both SINGLE_NODE_WRITER and READER_ONLY access mode specified")
}

if hasSingleReader && hasMultiReader {
return fmt.Errorf("both SINGLE_NODE_READER_ONLY and MULTI_NODE_READY_ONLY specified")
}

return nil
}

Expand Down
6 changes: 2 additions & 4 deletions pkg/gce-pd-csi-driver/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,20 +140,18 @@ func TestValidateVolumeCapabilities(t *testing.T) {
expErr: true,
},
{
name: "fail with reader + writer capabilities",
name: "success with reader + writer capabilities",
vc: []*csi.VolumeCapability{
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY),
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
},
expErr: true,
},
{
name: "fail with different reader capabilities",
name: "success with different reader capabilities",
vc: []*csi.VolumeCapability{
createVolumeCapability(csi.VolumeCapability_AccessMode_MULTI_NODE_READER_ONLY),
createVolumeCapability(csi.VolumeCapability_AccessMode_SINGLE_NODE_READER_ONLY),
},
expErr: true,
},
}

Expand Down