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

CSI volume expansion #74863

Merged
merged 5 commits into from
Mar 8, 2019
Merged

Conversation

gnufied
Copy link
Member

@gnufied gnufied commented Mar 3, 2019

Add support for CSI volume expansion.

Added tests for both online and offline expansion of CSI volumes.

Note to reviewers

/sig storage
cc @msau42 @jsafrane @mlmhl

xref kubernetes/enhancements#556

Add support for node side CSI volume expansion

@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 3, 2019
@k8s-ci-robot k8s-ci-robot added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 3, 2019
pkg/volume/csi/expander.go Outdated Show resolved Hide resolved
pkg/volume/csi/expander.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/testing Categorizes an issue or PR as relevant to SIG Testing. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 4, 2019
@gnufied
Copy link
Member Author

gnufied commented Mar 4, 2019

/kind feature
/priority important-soon

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 4, 2019
@gnufied gnufied changed the title Csi volume expansion CSI volume expansion Mar 4, 2019
)

func (c *csiPlugin) RequiresFSResize() bool {
// We could check plugin's node capability but we instead are going to rely on
Copy link
Member

Choose a reason for hiding this comment

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

This is different from how we implement skip attach. Can we be consistent in how we check a plugin's capability?

Copy link
Member Author

@gnufied gnufied Mar 5, 2019

Choose a reason for hiding this comment

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

But CanAttach check depends on CSIDriver field too right? Whereas this check is more static. I do not like changing the behaviour of FindByXXX function fwiw depending on feature tags and other dynamic things.

Copy link
Member

Choose a reason for hiding this comment

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

maybe we should consider changing skipAttach then (separately) cc @jsafrane

pkg/volume/csi/expander.go Outdated Show resolved Hide resolved
pkg/volume/csi/expander.go Outdated Show resolved Hide resolved
pkg/volume/csi/expander.go Show resolved Hide resolved

fsResizeFunc := func() (error, error) {
_, resizeError := og.resizeFileSystem(volumeToMount, volumeToMount.DevicePath, deviceMountPath, volumePlugin.GetPluginName())
if attachableVolumePlugin != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Are device mountable plugins supported here? (doesn't support attach but does support global device mount)

Copy link
Member

Choose a reason for hiding this comment

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

could use some unit tests here

Copy link
Member Author

Choose a reason for hiding this comment

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

The only volume type that is not attachable but implements device mountable interface is local storage. So for in-tree volumes this check should be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also if CSI plugin is not attachable but supports node expansion, it should be resized after node publish and hence we should be covered there too.

name: external-resizer-cfg
rules:
- apiGroups: [""]
resources: ["endpoints"]
Copy link
Member

Choose a reason for hiding this comment

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

we're trying to get all new components to use the Lease mechanism for leader election, not endpoints. cc @andrewsykim

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't use this rbac permission in e2e btw because our e2es run without leader election in external-resizer. The same applies to other sidecar containers too. I have kept it here just to have same version between here and external-resizer repo.

test/e2e/storage/csi_mock_volume.go Outdated Show resolved Hide resolved
test/e2e/storage/csi_mock_volume.go Show resolved Hide resolved
@thockin
Copy link
Member

thockin commented Mar 7, 2019

The vast majority of changes here are pkg/volume or test/e2e/storage - i think it's flyable.

vendor change LGTM

Copy link
Member

@saad-ali saad-ali left a comment

Choose a reason for hiding this comment

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

There are few changes to common code. The majority of functional changes are adding functionality to the CSI package and that functionality flag gated and off by default since this is an alpha feature.

/lgtm
/approve

@@ -676,15 +700,15 @@ func (og *operationGenerator) GenerateMountVolumeFunc(
}
}

func (og *operationGenerator) resizeFileSystem(volumeToMount VolumeToMount, devicePath, deviceMountPath, pluginName string) (simpleErr, detailedErr error) {
func (og *operationGenerator) resizeFileSystem(volumeToMount VolumeToMount, rsOpts volume.NodeResizeOptions, pluginName string) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: put a comment explaining what the expected values are that are returned here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will follow up this in a follow up.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 7, 2019
@msau42
Copy link
Member

msau42 commented Mar 7, 2019

/hold cancel
This feature is already planned and tracked for 1.14

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 7, 2019
@gnufied
Copy link
Member Author

gnufied commented Mar 7, 2019

/assign @smarterclayton

@smarterclayton
Copy link
Contributor

approving vendor change as per sig and other leads

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnufied, msau42, saad-ali, smarterclayton

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 Mar 7, 2019
Handle resize error in online resizing
Use NodeExpandable plugin to mark volumes that require node expansion
This enables us to pass CSI volume phase
Add some tests for checking node expansion
Add new tests for expander
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 8, 2019
@gnufied
Copy link
Member Author

gnufied commented Mar 8, 2019

I had to rebase because of a conflict. @jsafrane @tsmetana can you add lgtm again?

@jsafrane
Copy link
Member

jsafrane commented Mar 8, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 8, 2019
@k8s-ci-robot k8s-ci-robot merged commit 3624c74 into kubernetes:master Mar 8, 2019
}

if newSize.Value() < 0 {
return newSize, errors.New("size can not be less than 0")
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be helpful to include the negative value in the message

if err != nil {
return newSize, err
}
updatedQuantity := resource.NewQuantity(resp.CapacityBytes, resource.BinarySI)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to check that updatedQuantity is not nil?

}
for _, capability := range capabilities {
if capability.GetRpc().GetType() == csipbv1.NodeServiceCapability_RPC_EXPAND_VOLUME {
nodeExpandSet = true
Copy link
Contributor

Choose a reason for hiding this comment

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

We can break out of the loop here

@tedyu
Copy link
Contributor

tedyu commented Mar 8, 2019

Created #75203 for the last comment above.

chrischdi pushed a commit to chrischdi/kubernetes that referenced this pull request Jun 26, 2019
This cherry-picks the [74863](kubernetes#74863)
and allows us to use CSI volume expansion

This involves the following commits:
```
63eb25e Introduce feature gate for volume expansion
89d1de9 Rename ExandFS to NodeExpand
529cd71 Move resize function parameters to a new ResizeOptions type
a8f3187 Add  CSI volume resizing tests
1bd9ed0 Update csi library version
```
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. area/kubelet cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/storage Categorizes an issue or PR as relevant to SIG Storage. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.