Skip to content
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

Fixed creation of ControllerCreateVolumeRequest. #11238

Merged
merged 2 commits into from
Oct 6, 2021
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
3 changes: 3 additions & 0 deletions .changelog/11238.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where the client would incorrectly set an empty capacity range for CSI volume creation requests.
```
17 changes: 12 additions & 5 deletions client/structs/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,7 @@ type ClientCSIControllerCreateVolumeRequest struct {
func (req *ClientCSIControllerCreateVolumeRequest) ToCSIRequest() (*csi.ControllerCreateVolumeRequest, error) {

creq := &csi.ControllerCreateVolumeRequest{
Name: req.Name,
CapacityRange: &csi.CapacityRange{
RequiredBytes: req.CapacityMin,
LimitBytes: req.CapacityMax,
},
Name: req.Name,
VolumeCapabilities: []*csi.VolumeCapability{},
Parameters: req.Parameters,
Secrets: req.Secrets,
Expand All @@ -244,6 +240,17 @@ func (req *ClientCSIControllerCreateVolumeRequest) ToCSIRequest() (*csi.Controll
// TODO: topology is not yet supported
AccessibilityRequirements: &csi.TopologyRequirement{},
}

// The CSI spec requires that at least one of the fields in CapacityRange
// must be defined. Fields set to 0 are considered unspecified and the
// CreateVolumeRequest should not send an invalid value.
if req.CapacityMin != 0 || req.CapacityMax != 0 {
creq.CapacityRange = &csi.CapacityRange{
RequiredBytes: req.CapacityMin,
LimitBytes: req.CapacityMax,
}
}

for _, cap := range req.VolumeCapabilities {
ccap, err := csi.VolumeCapabilityFromStructs(cap.AttachmentMode, cap.AccessMode, req.MountOptions)
if err != nil {
Expand Down