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 pvc metadata to createvolume req #399

Merged
merged 1 commit into from Feb 7, 2020

Conversation

zetsub0u
Copy link
Contributor

@zetsub0u zetsub0u commented Jan 17, 2020

Co-authored-by: abrden agustina.barbetta@gmail.com

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test
/kind feature
/kind flake

What this PR does / why we need it:
Add PVC metadata to plugin call in the CreateVolume operation for it to be able to query for more information if needed during volume creation.
Which issue(s) this PR fixes:

Fixes #370

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

* Adds --extraCreateMetadata flag which, when enabled, will inject parameters onto CreateVolume driver requests with PVC and PV metadata.
  Injected keys:
  - csi.storage.k8s.io/pvc/name
  - csi.storage.k8s.io/pvc/namespace
  - csi.storage.k8s.io/pv/name

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. labels Jan 17, 2020
@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Jan 17, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @zetsub0u!

It looks like this is your first PR to kubernetes-csi/external-provisioner 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-csi/external-provisioner has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @zetsub0u. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jan 17, 2020
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jan 17, 2020
@aibarbetta
Copy link
Contributor

/assign @msau42

@davidz627
Copy link
Contributor

@zetsub0u please sign the CLA
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 18, 2020
@zetsub0u
Copy link
Contributor Author

Hi, yes i followed the steps but i'm not getting the document to sign via email and i'm trying to figure out what to do now. Also i'll check the unittests, i completely forgot to run them as it was a simple change.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 18, 2020
@zetsub0u
Copy link
Contributor Author

CLA signed, i guess need to wait for the bot to retest.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 19, 2020
Copy link
Contributor

@davidz627 davidz627 left a comment

Choose a reason for hiding this comment

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

looks good, overall I think the major thing is we'd want to gate this on the binary and have it off by default. cc @jsafrane @saad-ali @msau42

@@ -101,6 +101,11 @@ const (
nodePublishSecretNameKey = "csiNodePublishSecretName"
nodePublishSecretNamespaceKey = "csiNodePublishSecretNamespace"

// PVC's name and namespace passed on create requests, useful for the plugin to query for extra data
// prior to performing operations
pvcNameKey = "kubernetes.io/created-for/pvc/name"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we also add pv name as one of these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We thought about this but, the PV name is generated in the provisioner and passed in the request as the Name field already and always, do you see any need for adding it into the parameters also?

Copy link
Contributor

Choose a reason for hiding this comment

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

would prefer it is added to the parameters as well. Using it as the name is just an implementation choice in the provisioner not an explicit contract so it could technically change.

@@ -567,6 +572,10 @@ func (p *csiProvisioner) ProvisionExt(options controller.ProvisionOptions) (*v1.
return nil, controller.ProvisioningFinished, fmt.Errorf("failed to strip CSI Parameters of prefixed keys: %v", err)
}

// add pvc metadata to request for use by the plugin
req.Parameters[pvcNameKey] = options.PVC.GetName()
Copy link
Contributor

Choose a reason for hiding this comment

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

we should gate this behind a feature flag or binary flag of some sort. This is a breaking change for drivers that do validation on parameters and don't expect extra stuff coming in. (this should default to off and you can turn it on if you want this information)

Copy link
Contributor Author

@zetsub0u zetsub0u Jan 24, 2020

Choose a reason for hiding this comment

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

It seems like the featureGate flag used here is being pulled from the api server, i'm not too sure if i should extend it with custom provisioner-only feature gates or just add a boolean flag say --inject-pvc-metadata, what do you think is the best approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think a boolean flag is fine. I suck at naming so I can't come up with another solution but I don't think it should contain pvc in it since we will inject pv/pvc name. It should also have some sort of information of "where" it is injecting the metadata. extra-create-params-metadata?

Can you add a comment disclaimer as a flag comment along the lines of:
This metadata should only be used for tagging or descriptive purposes and should in no circumstances be consumed and acted on programatically by a CSI Driver.

Copy link

Choose a reason for hiding this comment

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

Are we going to follow some sort of Alpha->Beta->GA plan for this flag?
If so can we include the stage in the name '--extra-create-params=alpha-pvc'?

Copy link
Contributor

Choose a reason for hiding this comment

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

no need for a stage - just a single flag should be 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.

Or do you prefer

 --enable-extra-metadata-for-create-req   If set, add pv/pvc metadata to plugin create requests as parameters.

I have both implement, just let me know which makes more sense.

Copy link

Choose a reason for hiding this comment

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

I personally prefer the feature gate and have it go to default at some point.

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't set this as a default unless we bump the major version of the provisioner - it is a breaking change to drivers as this is adding "unexpected" parameters to their CreateVolume API call. I don't really see the value of feature gating this as the intention for that is to slowly "graduate" features to minimize risk. I wouldn't really consider this a risky feature in terms of potential impact or implementation

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'll add a standard flag for this, any suggestions on naming? Anything else needing change? I couldn't find any place to document this feature for consumption...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also open an issue to track changing it to default, and we can add it to the 2.0 milestone

Copy link
Contributor

@davidz627 davidz627 left a comment

Choose a reason for hiding this comment

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

mostly lgtm

leaderElectionType = flag.String("leader-election-type", "endpoints", "the type of leader election, options are 'endpoints' (default) or 'leases' (strongly recommended). The 'endpoints' option is deprecated in favor of 'leases'.")
leaderElectionNamespace = flag.String("leader-election-namespace", "", "Namespace where the leader election resource lives. Defaults to the pod namespace if not set.")
strictTopology = flag.Bool("strict-topology", false, "Passes only selected node topology to CreateVolume Request, unlike default behavior of passing aggregated cluster topologies that match with topology keys of the selected node.")
enableExtraMetadataForCreateReq = flag.Bool("enable-extra-metadata-for-create-req", false, "If set, add pv/pvc metadata to plugin create requests as parameters.")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: enable not necessary (implied by boolean flag), req not required (implied by create)
extra-create-metadata is probably 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, i hate naming things :)

// PV and PVC metadata, used for sending to drivers in the create requests, added as parameters, optional.
pvcNameKey = "kubernetes.io/created-for/pvc/name"
pvcNamespaceKey = "kubernetes.io/created-for/pvc/namespace"
pvNameKey = "kubernetes.io/created-for/pv/name"
Copy link
Contributor

Choose a reason for hiding this comment

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

cc @saad-ali is this an acceptable prefix? maybe it should be one of the volume specific prefixes?

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 prefer to use the same prefix as for pod info on mount: csi.storage.k8s.io/...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, updated.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2020
@zetsub0u
Copy link
Contributor Author

@davidz627 Let me know if you need any other changes. Thanks.

cmd/csi-provisioner/csi-provisioner.go Show resolved Hide resolved
Comment on lines 108 to 110
pvcNameKey = "csi.storage.k8s.io/created-for/pvc/name"
pvcNamespaceKey = "csi.storage.k8s.io/created-for/pvc/namespace"
pvNameKey = "csi.storage.k8s.io/created-for/pv/name"
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to use the same schema we use in NodePublish?

csi.storage.k8s.io/pvc/name
csi.storage.k8s.io/pvc/namespace
csi.storage.k8s.io/pv/name

I know CSI drivers that support migration need to translate it to created-for/ format, still, it would make life of all the non-migrating drivers a bit easier.

@jsafrane
Copy link
Contributor

jsafrane commented Feb 3, 2020

Oh, and please edit the first comment and add useful release note there (instead of None) - this is user visible change and actually it's probably going to be highlight of the new release ;-).

@zetsub0u
Copy link
Contributor Author

zetsub0u commented Feb 6, 2020

Updated the keys for the parameters and the Release notes.

@davidz627
Copy link
Contributor

@zetsub0u Thanks for the change! Please squash commits to 1 well described commit :)
/approve

Adds --extraCreateMetadata flag which, when enabled, will inject parameters onto CreateVolume driver requests with PVC and PV metadata.
  Injected keys:
  - csi.storage.k8s.io/pvc/name
  - csi.storage.k8s.io/pvc/namespace
  - csi.storage.k8s.io/pv/name

Co-authored-by: abrden <agustina.barbetta@gmail.com>
@jsafrane
Copy link
Contributor

jsafrane commented Feb 7, 2020

/lgtm
thanks a lot!

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

jsafrane commented Feb 7, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: davidz627, jsafrane, zetsub0u

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 7, 2020
@k8s-ci-robot k8s-ci-robot merged commit 4aa560e into kubernetes-csi:master Feb 7, 2020
@zetsub0u
Copy link
Contributor Author

zetsub0u commented Feb 7, 2020

Thanks! We really needed this feature and didn't want to fork :)

databus23 added a commit to sapcc/cloud-provider-openstack that referenced this pull request Apr 22, 2021
the external-csi provisioner optionally injects metadata in the CreateVolume that we now preserve as tags on the volume.

kubernetes-csi/external-provisioner#399
databus23 added a commit to sapcc/cloud-provider-openstack that referenced this pull request Apr 22, 2021
The external CSI provisioner optionally injects metadata in the CreateVolume that we can pass onto the volume as additional tags.
See kubernetes-csi/external-provisioner#399

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>
databus23 added a commit to sapcc/cloud-provider-openstack that referenced this pull request Apr 22, 2021
The external CSI provisioner optionally injects metadata in the CreateVolume that we can pass onto the volume as additional tags.
See kubernetes-csi/external-provisioner#399

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>
databus23 added a commit to sapcc/cloud-provider-openstack that referenced this pull request Apr 28, 2021
The external CSI provisioner optionally injects metadata in the CreateVolume that we can pass onto the volume as additional tags.
See kubernetes-csi/external-provisioner#399

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>
k8s-ci-robot pushed a commit to kubernetes/cloud-provider-openstack that referenced this pull request Apr 29, 2021
* [cinder-csi-plugin] Tag volume with optional metadata

The external CSI provisioner optionally injects metadata in the CreateVolume that we can pass onto the volume as additional tags.
See kubernetes-csi/external-provisioner#399

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>

* Add --extra-create-metadata to csi-provisoner manifests

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>

* Add unit test for extra metadata

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>

* Bump chart again.

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>
powellchristoph pushed a commit to powellchristoph/cloud-provider-openstack that referenced this pull request Jan 19, 2022
…tes#1492)

* [cinder-csi-plugin] Tag volume with optional metadata

The external CSI provisioner optionally injects metadata in the CreateVolume that we can pass onto the volume as additional tags.
See kubernetes-csi/external-provisioner#399

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>

* Add --extra-create-metadata to csi-provisoner manifests

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>

* Add unit test for extra metadata

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>

* Bump chart again.

Signed-off-by: Fabian Ruff <fabian.ruff@sap.com>
kbsonlong pushed a commit to kbsonlong/external-provisioner that referenced this pull request Dec 29, 2023
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/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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pass k8s API metadata through parameters in CreateVolume
9 participants