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 implement for CSI plugin #7

Merged
merged 2 commits into from
Feb 27, 2019
Merged

Conversation

mlmhl
Copy link
Contributor

@mlmhl mlmhl commented Jan 30, 2019

This PR adds an initial implement of CSI resize plugin. Currently we can test this by the csi-test tool with PR kubernetes-csi/csi-test#160

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 30, 2019
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Jan 30, 2019
@mlmhl
Copy link
Contributor Author

mlmhl commented Jan 30, 2019

/assign @gnufied


ctx, cancel := timeoutCtx(r.timeout)
defer cancel()
// TODO: Get secrets used for expansion operation.
Copy link

Choose a reason for hiding this comment

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

you can get the secret here and remove the TODO :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure how to get these secrets. The external-attacher got publish/stage secrets from the PV object directly, and the external-snapshotter got snapshot secrets from VolumeSnapshotClass.Parameters. So which way should we adopt? Add a ControllerExpandSecretRef field to CSIPersistentVolumeSource or just fetch these secrets from StorageClass.Parameters?

cc @gnufied

Copy link

Choose a reason for hiding this comment

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

resizer needs admin credentials, not publish/stage credentials (used by attacher), in most cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets do what external-provisioner does. It also fetches secrets from SC. We could use same secret that are being used for provisioning. cc @msau42

Copy link
Collaborator

Choose a reason for hiding this comment

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

Which secret needs the be used? Same as provision? Or do we need a new secret for resize?

Copy link
Collaborator

Choose a reason for hiding this comment

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

PV source

Copy link
Contributor

Choose a reason for hiding this comment

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

PV source still refers to CSIPersistentVolumeSource right? So no - I do not think we need resizing secrets there.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's where we put all the other non provisioning secrets. So you don't need to reference storageclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will fetch secrets from SC with a separate name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of fetching secrets directly from the storageclass, can it be added as a parameter to the CSIPersistentVolumeSource? That way all the secret fetching/templating logic can be confined to just the external-provisioner.

// New creates a new CSI client.
func New(address string, timeout time.Duration) (Client, error) {
conn, err := newGRPCConnection(address, timeout)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets use connection interface from kubernetes-csi/csi-lib-utils#11 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, these util functions make sense to me, I will update this later.

)

// NewCSIResizer creates a new resizer responsible for resizing CSI volumes.
func NewCSIResizer(address string, timeout time.Duration) (Resizer, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It is bit odd that all these functions take timeout parameter but convert this into a context anyways. Shouldn't we just be passing Context here in the first place?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)), so I think we need to create the context just before each CSI operation. If we passed a Context to NewCSIResizer method, it means the total time consumed by all CSI operations(waitDriverReady, getDriverName, etc.) should not exceed timeout. This is not what we want.


ctx, cancel := timeoutCtx(r.timeout)
defer cancel()
// TODO: Get secrets used for expansion operation.
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets do what external-provisioner does. It also fetches secrets from SC. We could use same secret that are being used for provisioning. cc @msau42

return nil
}

func getDriverName(client csi.Client, timeout time.Duration) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would preferably convert these functions to directly accept contexts rather than converting them around.

@gnufied
Copy link
Contributor

gnufied commented Feb 22, 2019

@mlmhl can you update this PR with fetching secret from SC and then we can mostly merge this.

@mlmhl
Copy link
Contributor Author

mlmhl commented Feb 22, 2019

@gnufied I've updated this PR to fetch secrets from StorageClass's parameters, with different name/namespace key, PTAL :)

ps: We should add these keys to external-provisioner too, as it needs to remove these keys from parameters before passing to the driver, see this function. I will post a PR to do this after this PR merged. cc @msau42

What's more, I haven't introduce the connection interface in https://github.com/kubernetes-csi/csi-lib-utils due to the dependency conflict: csi-lib-utils requires https://github.com/container-storage-interface/spec v1.0.0, but external-resizer requires master. I think we can resolve this in a follow up PR once csi-lib-utils are updated to use the latest CSI spec package.

@msau42
Copy link
Collaborator

msau42 commented Feb 22, 2019

I can help update CSI lib utils to use the master CSI spec

@mlmhl
Copy link
Contributor Author

mlmhl commented Feb 23, 2019

Thanks @msau42 !

@gnufied
Copy link
Contributor

gnufied commented Feb 26, 2019

@saad-ali should we consider tagging a new CSI release since we need it for resizing?

@saad-ali
Copy link
Member

@gnufied Yes. Please please start a thread (propose cutting a CSI 1.1 and a timeline) and add it it to the agenda of the next CSI meeting.

@gnufied
Copy link
Contributor

gnufied commented Feb 27, 2019

lets merge this for now rather than being blocked on csi tag or csi-lib being updated. Also, for alpha release using secrets from SC is fine, we will update this code to fetch from "new place", once that decision is finalized in kubernetes-csi/external-provisioner#233

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 27, 2019
@gnufied
Copy link
Contributor

gnufied commented Feb 27, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gnufied, mlmhl

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 Feb 27, 2019
@k8s-ci-robot k8s-ci-robot merged commit 237ba95 into kubernetes-csi:master Feb 27, 2019
jsafrane pushed a commit to jsafrane/external-resizer that referenced this pull request Apr 7, 2020
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

6 participants