Skip to content
This repository was archived by the owner on Mar 16, 2021. It is now read-only.

Commit b776760

Browse files
authored
Merge pull request #129 from pohly/hostpath-1.0.0-backport-2
backport: hostpath: refuse to create block volumes
2 parents 7071333 + 03bb235 commit b776760

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

pkg/hostpath/controllerserver.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,21 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
5757
if len(req.GetName()) == 0 {
5858
return nil, status.Error(codes.InvalidArgument, "Name missing in request")
5959
}
60-
if req.GetVolumeCapabilities() == nil {
60+
caps := req.GetVolumeCapabilities()
61+
if caps == nil {
6162
return nil, status.Error(codes.InvalidArgument, "Volume Capabilities missing in request")
6263
}
64+
for _, cap := range caps {
65+
if cap.GetBlock() != nil {
66+
return nil, status.Error(codes.Unimplemented, "Block Volume not supported")
67+
}
68+
}
69+
// A real driver would also need to check that the other
70+
// fields in VolumeCapabilities are sane. The check above is
71+
// just enough to pass the "[Testpattern: Dynamic PV (block
72+
// volmode)] volumeMode should fail in binding dynamic
73+
// provisioned PV to PVC" storage E2E test.
74+
6375
// Need to check for already existing volume name, and if found
6476
// check for the requested capacity and already allocated capacity
6577
if exVol, err := getVolumeByName(req.GetName()); err == nil {

0 commit comments

Comments
 (0)