-
Notifications
You must be signed in to change notification settings - Fork 62
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
skip resizing volume when extent is less than the minimum of 1MB #196
skip resizing volume when extent is less than the minimum of 1MB #196
Conversation
Welcome @divyenpatel! |
Hi @divyenpatel. Thanks for your PR. I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
It'd be nice to have an integration test too, the code is in integrationtests/volume_v2alpha1_test.go
/ok-to-test |
/ok-to-test |
/assign @jingxu97 |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: divyenpatel The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
eff216a
to
9362a2b
Compare
9362a2b
to
8b6df23
Compare
/test pull-kubernetes-csi-csi-proxy-integration |
just want to understand when this scenario might happen. In your test case, you increase from 2GB to 3GB, how it caused failure? |
We created 2 GB volume and then expanded the volume size to 3 GB, without creating the filesystem on the volume. This issue is not happening for the case, when we create a 2 GB volume, create a pod using this volume, then we expand the disk to 3 GB and re-create the pod to expand the filesystem. |
603b06b
to
fd11306
Compare
@jingxu97 @mauriciopoppe I have squashed all commits. Can we merge this PR? |
it looks good to me, @jingxu97 will lgtm and approve |
@divyenpatel this failure only happen in Windows case, right? |
cc @gnufied Do you think resize controller can avoid triggering resize in this scenario? When volume is provisioned with 2GB, it is not formatted. Then it gets resized to 3GB and gets formatted. Then in this case, no resize of file system is needed. |
If we return error in csi-proxy api, then in current logic, all the driver might need to modify to handle this case, otherwise it will fail here. |
Isn't |
I might be wrong, in this case, nodeexpand is only called once. The volume is first formatted with 3GB, but in windows, actual file system size will be less then 3GB. Then it calls nodeExpand trying to expand to 3GB and hit the error |
It sounds like a driver bug. If file system was on 3GB disk (i.e I am not saying file system size but rather total disk space on which file system exists) and kubelet asked to expand to 3GB again, then driver should return success. Why does the driver returns error? Given current behaviour - |
if finalSize-currentSize < MinimumExpandSize { | ||
return status.Errorf(codes.OutOfRange, | ||
"minimum extent size is 1 MB. Skip resize for volume %s from currentBytes=%d to wantedBytes=%d ", volumeID, currentSize, finalSize) | ||
} |
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.
Does this fixes the issue we observed btw? It sounds like - this will prevent node-expansion if increased size is less than 1MB? Basically it is not skipping - we are now returning an error.
This is also not consistent with how sizing works in other places in k8s. For example - on EBS I can't allocate a 1MB disk and if user asks for a 1MB disk, we make 1GB disk and provide it, rather than throwing an error.
I checked some code here, so during FormatVolume it uses the following command, no size needs to be specifies during format. System should try to format the disk as much as it can after reserving some space for system use. With 3GB disk, the file system size seems 3204382720bytes
When driver calls ResizeVolume, it does not pass a size either which means resize to the max value that this disk can. So maxSize is calculated with following command. For 3GB disk, it returns 3204431360bytes
The code also get the current file system size with following command, the value is 3204382720bytes
If maxSize is the same as current size, the current logic will skip resize and return success. In this case it happens that maxSize is a little bit larger than current size, so it continues to run resize command and failed. I am wondering how linux handle this case, when tries to resize the volume which is already formatted under the same disk capacity using command like "resize2fs" for ext file system. Two things I am thinking
|
@jingxu97 I have checked 4 CSI drivers, all of them call resize with SizeBytes 0 to use the maximum available size. https://github.com/kubernetes-sigs/azuredisk-csi-driver/blob/master/pkg/mounter/safe_mounter_windows.go#L329 so this is affect all these drivers. so to be on the safe side do you suggest checking if supplied SizeBytes is 0, and we find |
Why doesn't
I wonder if there is a way to get disk size on which file system is, vs file system size. In Linux it is possible to get disk size on which file system exists vs file system size. That is one way to determine if file system on the disk needs expansion. This is similar to problem we ran into when a snapshot can be restored to size larger than original volume and hence we had to calculate disk space on which file system exists (which is very different from file system size). Code in Linux - https://github.com/kubernetes/mount-utils/blob/master/resizefs_linux.go#L106 |
@divyenpatel: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
We checked a few drivers, when calling resize, none of them pass a size value. I think it tries to resize to the max size that disk can possible hold. I tried command resize2fs on a disk with file system already exist, it returns
So for Linux, resize the filesystem that is already the max size from that disk can pass without error. This is also confirmed with @divyenpatel |
I agree with the logic. Seems like linux can handle this well without extra logic to check, but Windows we have to handle it ourselves. |
@divyenpatel just to check the status of this PR? |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
do we still need to merge this change? |
/remove-lifecycle stale |
Can we accept that this patch is adequate for a temporary fix and that we'll fix it with a better one soon? If that's OK, I'll file another bug to create a better patch and work on it next. |
I don't have strong objection, @gnufied WDYT? |
Development of the client/server model has moved to the v1.x branch, please change the base branch to v1.x |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
What type of PR is this?
/kind bug
What this PR does / why we need it:
This PR is skipping resize of the volume when extent is less than the minimum of 1MB
Which issue(s) this PR fixes:
Fixes #195
Special notes for your reviewer:
Validated changes with vSphere CSI Driver. Volume is getting expanded when the volume is resized before creating a filesystem on it.
Does this PR introduce a user-facing change?: