Skip to content

Commit

Permalink
Fixed creation of ControllerCreateVolumeRequest.
Browse files Browse the repository at this point in the history
`CapacityRange` should only be set if `RequiredBytes` and/or
`LimitBytes` are set.
  • Loading branch information
apollo13 committed Oct 4, 2021
1 parent 524ffbd commit 71cfa2f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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 and empty capacity range for CSI volume creation requests.
```
12 changes: 7 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,12 @@ func (req *ClientCSIControllerCreateVolumeRequest) ToCSIRequest() (*csi.Controll
// TODO: topology is not yet supported
AccessibilityRequirements: &csi.TopologyRequirement{},
}
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

0 comments on commit 71cfa2f

Please sign in to comment.