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

Add support to resize Portworx volume #62308

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

harsh-px
Copy link
Contributor

Signed-off-by: Harsh Desai harsh@portworx.com

What this PR does / why we need it:

This PR adds support in the Portworx volume plugin to expand an existing PVC.

Which issue(s) this PR fixes:

Closes #62305

Release note:

Add support to resize Portworx volumes.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 10, 2018
Copy link
Contributor

@lpabon lpabon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

spec *volume.Spec,
newSize resource.Quantity,
oldSize resource.Quantity) (resource.Quantity, error) {
glog.Infof("Expanding: %s from %v to %v", spec.Name(), oldSize, newSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using level 4 log?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to level 4 logging.

return oldSize, err
}

glog.Infof("Successfully resized %s to %v", spec.Name(), newSize)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest incremental

@@ -38,6 +41,7 @@ const (
pvcNamespaceLabel = "namespace"
pxServiceName = "portworx-service"
pxDriverName = "pxd-sched"
oneGig = 1024 * 1024 * 1024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use oneGi instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this and now using existing functions in https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/util/util.go

return fmt.Errorf("failed to inspect Portworx volume: %s. Found: %d volumes", spec.Name(), len(vols))
}

vol := vols[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only the first volume will be resized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because we inspected one volume above. So only one volume is expected is the response. Line 200 also explicitly makes that check. ResizeVolume is a per-volume call.


func capacityToGB(capacity resource.Quantity) int {
return int(volutil.RoundUpSize(capacity.Value(), oneGig))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is already https://github.com/kubernetes/kubernetes/blob/master/pkg/volume/util/util.go#L372

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

@gnufied
Copy link
Member

gnufied commented Apr 10, 2018

/ok-to-test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 10, 2018
@harsh-px
Copy link
Contributor Author

@dixudx / @gnufied I have fixed the review comments and the tests are passing.

@dixudx
Copy link
Member

dixudx commented Apr 13, 2018

@harsh-px Would you please rebase your commits. Thanks.

I'll lgtm.

@harsh-px
Copy link
Contributor Author

@dixudx done.

@dixudx
Copy link
Member

dixudx commented Apr 16, 2018

/lgtm

ping @msau42 @jsafrane for approval. Thanks.
/cc @kubernetes/sig-storage-api-reviews

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. lgtm "Looks good to me", indicates that a PR is ready to be merged. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Apr 16, 2018
@harsh-px
Copy link
Contributor Author

@deads2k and @gnufied can you approve?

@@ -56,7 +59,7 @@ func (util *PortworxVolumeUtil) CreateVolume(p *portworxVolumeProvisioner) (stri

capacity := p.options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)]
// Portworx Volumes are specified in GB
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this comment says Portworx volumes are specified in GB and then code proceeds to use GiB ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest incremental.

newSize resource.Quantity,
oldSize resource.Quantity) (resource.Quantity, error) {
glog.V(4).Infof("Expanding: %s from %v to %v", spec.Name(), oldSize, newSize)
err := plugin.util.ResizeVolume(spec, newSize, plugin.host)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function should be idempotent. If portworx volume already has the user requested size, ExpandVolumeDevice should be a no-op followed by a successful response. Please see other volume plugins as an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnufied the Portworx driver implementation on the server side is already idempotent. So invoking it multiple times will have the same effect as it internally checks if the volume has the size. So I don't need any logic here on the client side. Best to keep it simple.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another reason for keeping this idempotent in Kubernetes rather than in Portworx server side. Lets say:

  1. User created a PVC of 5GB size and is matched with a PV which is of 7GiB size.
  2. Later on User edits the PVC to be 6GiB. Kuberenetes may still call ExpandVolumeDevice even though underlying PV already matches the requested size.
  3. What happens in portworx server side now? Will it shrink existing 7GiB disk to 6GiB or will it return an error?

Obviously shrinking will be bad. We never shrink volumes in Kubernetes. Returning an error will be bad too. Even if theoretically Portworx in Server side does the "right thing" and returns successful response - there is no guarantee that the behaviour will remain the same always. That is why - it is important to not rely on Portworx behaviour in server side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gnufied good point ! Updated the review with check to see if existing volume is already equal or greater than requested size.


vol := vols[0]
vol.Spec.Size = uint64(volutil.RoundUpToGiB(newSize))
return driver.Set(spec.Name(), vol.Locator, vol.Spec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to get size after resizing? The reason most volume plugins returns "new size" from this function is because - after alignment to GB or GiB boundaries, actual volume size may be different than user requested size(but as long as it is more than user requested size we are fine)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Added check in the latest incremental if the size actually got updated.

@gnufied
Copy link
Member

gnufied commented Apr 17, 2018

Nearly there. Please make sure plugin uses one unit throughout the code (GB or GiB). Also - ideally ExpandVolumeDevice should be idempotent, if somehow we can't do that for portworx then the idempotency should be handled by portworx itself. Under no circumstance - if user requested 15GB space and volume is of >=15GB size, an error should be thrown from ExpandVolumeDevice function.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 17, 2018
@harsh-px harsh-px force-pushed the px-resize-master branch 2 times, most recently from fa522a9 to 7753d1a Compare April 19, 2018 16:49
}

updatedVol := vols[0]
if updatedVol.Spec.Size != vol.Spec.Size {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to check exact equality, may be just updatedVol.Size >= vol.Size should be sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Now I'm allowing the updated volume to be greater than the requested size.

@harsh-px
Copy link
Contributor Author

/retest

@gnufied
Copy link
Member

gnufied commented Apr 19, 2018

@harsh-px please squash the commits.

Closes kubernetes#62305

Signed-off-by: Harsh Desai <harsh@portworx.com>

update comment and variable references to GiB

Signed-off-by: Harsh Desai <harsh@portworx.com>

explicitly check volume size after resize and fix size volume spec

Signed-off-by: Harsh Desai <harsh@portworx.com>

If Portworx volume is already greater than new size, skip resize

Signed-off-by: Harsh Desai <harsh@portworx.com>

Allow updated volume to be greater than requested size

Signed-off-by: Harsh Desai <harsh@portworx.com>
@harsh-px
Copy link
Contributor Author

@gnufied Squashed the changes. It seems the tests for failing due to an automation issue.

ERROR: (gcloud.auth.activate-service-account) There was a problem refreshing your current auth tokens: Unable to find the server at accounts.google.com

I'm going to retry these.

/retest

@harsh-px
Copy link
Contributor Author

/retest

@gnufied
Copy link
Member

gnufied commented Apr 19, 2018

Looks good to me. Assinging @deads2k for approval

/lgtm
/assign @deads2k

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 19, 2018
@deads2k
Copy link
Contributor

deads2k commented Apr 19, 2018

/approve

approving the admission changes.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, dixudx, gnufied, harsh-px

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 19, 2018
@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 59592, 62308, 62523, 62635, 62243). If you want to cherry-pick this change to another branch, please follow the instructions here.

@gnufied
Copy link
Member

gnufied commented Jul 10, 2018

@harsh-px I was just reviewing some of the stuff for a blog post and noticed that Portworx still returns false from RequiresFSReisze function. Is that an oversight? Does this needs fixing. I don't know much about portworx.. cc @lpabon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add resize support for Portworx volumes
7 participants