-
Notifications
You must be signed in to change notification settings - Fork 108
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
Set storage size to minimum volume size #441
Conversation
/fixes #435 |
FYI - @timoreimann |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small suggestions, otherwise all good. 👍
driver/controller.go
Outdated
@@ -955,7 +955,11 @@ func extractStorage(capRange *csi.CapacityRange) (int64, error) { | |||
} | |||
|
|||
if requiredSet && !limitSet && requiredBytes < minimumVolumeSizeInBytes { | |||
return 0, fmt.Errorf("required (%v) can not be less than minimum supported volume size (%v)", formatBytes(requiredBytes), formatBytes(minimumVolumeSizeInBytes)) | |||
d.log.WithFields(logrus.Fields{ | |||
"requiredBytes": formatBytes(requiredBytes), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind using camel case here and on the field below in order to be consistent with the existing style?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, updated.
"requiredBytes": formatBytes(requiredBytes), | ||
"minimumVolumeSizeInBytes": formatBytes(minimumVolumeSizeInBytes), | ||
}).Warn("requiredBytes is less than minimum supported volume size, setting requiredBytes default to minimumVolumeSizeBytes") | ||
return minimumVolumeSizeInBytes, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's say "minimum volume size" to not give the impression that minimumVolumeSizeBytes
is a known value from the CSI spec (which requiredBytes
is only).
@timoreimann - please re-review when you get a chance. Thanks ! |
driver/controller_test.go
Outdated
@@ -181,14 +181,20 @@ func (*fakeTagsDriver) UntagResources(context.Context, string, *godo.UntagResour | |||
} | |||
|
|||
func TestControllerExpandVolume(t *testing.T) { | |||
default_volume := &godo.Volume{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use snake case here, i.e., defaultVolume
.
driver/controller_test.go
Outdated
@@ -200,6 +206,10 @@ func TestControllerExpandVolume(t *testing.T) { | |||
}, | |||
{ | |||
name: "requested size less than minimum supported size", | |||
godo_volume: &godo.Volume{ | |||
ID: "volume-id", | |||
SizeGigaBytes: (minimumVolumeSizeInBytes / giB), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we subtract a bit to make sure we're really below the minimum size (and not hitting it exactly)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is size in gb
I don't find a way to go less than 1 Gi
. I did change that value to 1
to make it simpler. Please suggest if I am missing anything here.
driver/controller_test.go
Outdated
}{ | ||
{ | ||
name: "request exceeds maximum supported size", | ||
name: "request exceeds maximum supported size", | ||
godo_volume: default_volume, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of requiring to define the volume for every current and future test case, could we make it optional and let the test body pick defaultVolume
if the volume from the test case struct is nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, updated.
driver/controller_test.go
Outdated
req *csi.ControllerExpandVolumeRequest | ||
resp *csi.ControllerExpandVolumeResponse | ||
err error | ||
godo_volume *godo.Volume |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd name this just volume
since the type is embedded in the *godo.Volume
type. This would also keep the diff in this PR slightly smaller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done.
Merging since PRs from forks still cannot leverage Github Actions secrets, and the unit tests should suffice here. |
Hey, @srikiz - Thanks a ton for this sweet PR! 😄 Would you please shoot me an email when you get a chance? |
Setting required Bytes to minimum volume size (1Gi) in case it is less than the minimum volume size.
Tested locally and works as expected.
Input pvc & pod for test:
Logs for reference:
time="2022-06-24T16:23:44Z" level=warning msg="requiredBytes is less than minimum supported volume size, setting requiredBytes default to minimumVolumeSizeBytes" host_id=303920350 minimumVolumeSizeInBytes=1Gi region=blr1 requiredBytes=1 version=v4.1.0