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

Replace MutatorConfig with CreatePVCPrimeFn that allows custom creation of a PVC #201

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pwschuurman
Copy link

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: This is a follow-up to #176. While useful, the previous approach of mutating a PVC prior to creation is not flexible enough for some providers. This enables some functionality for implementations to perform some custom steps prior to the create of a PVCPrime.

  • Remove MutatorConfig to Volume Populator Controller
  • Add a CreatePVCPrimeFn function to the ProviderFunctionConfig interface, to allow for custom PVC prime creation

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Add optional CreatePVCPrimeFn to ProviderFunctionConfig to allow a custom PVC prime to be created for volume population. Remove the existing PvcPrimeMutator and MutatorConfig as CreatePVCPrimeFn provides the same functionality with more flexibility.

@k8s-ci-robot
Copy link
Contributor

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Feb 1, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pwschuurman
Once this PR has been reviewed and has the lgtm label, please assign saad-ali for approval. For more information see the Code Review Process.

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pwschuurman
Copy link
Author

/retest

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 1, 2025
if err != nil {
c.recorder.Eventf(pvc, corev1.EventTypeWarning, reasonPVCPrimeMutatorError, "Failed to mutate populator pvcPrime: %s", err)
if c.providerFunctionConfig != nil && c.providerFunctionConfig.CreatePVCPrimeFn != nil {
if pvcPrime, err = c.providerFunctionConfig.CreatePVCPrimeFn(ctx, *params); 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.

The only thing I'm not sure about is that there is a check of "" == pvcPrime.Spec.VolumeName[1]. Previous implementation was based on dynamic provisioning PV which will guarantee the check only get passed when the PVC' gets created. With CreatePVCPrimeFn if there is a static provisioned PV, is it possible that pvcPrime.Spec.VolumeName gets set, kubeClient.create.pvc' gets stuck for some reason, but the "" == pvcPrime.Spec.VolumeName pass?

[1]https://github.com/kubernetes-csi/lib-volume-populator/blob/master/populator-machinery/controller.go#L773

Copy link
Author

Choose a reason for hiding this comment

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

That would be up to the client implementation. But, if the client uses static provisioning, the proper way to do this is to create a PV with a claimRef, and then a PVC without a volumeName set. The volume controller then binds the two, and sets volumeName.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a recommendation but not a requirement that users leave PVC.spec.volumeName unset.

Copy link
Contributor

Choose a reason for hiding this comment

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

This flow probably should get added to the KEP or README later.

@pwschuurman
Copy link
Author

/retest

@pwschuurman pwschuurman marked this pull request as ready for review February 6, 2025 17:05
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 6, 2025
@dannawang0221
Copy link
Contributor

/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 6, 2025
@pwschuurman
Copy link
Author

/cc @sunnylovestiramisu
/assign @msau42

@pwschuurman pwschuurman marked this pull request as draft February 13, 2025 00:58
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Feb 13, 2025
@sunnylovestiramisu
Copy link
Contributor

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants