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

Added controller for PVC deletion #422

Merged
merged 10 commits into from
Mar 16, 2020

Conversation

Danil-Grigorev
Copy link
Contributor

@Danil-Grigorev Danil-Grigorev commented Mar 11, 2020

/kind feature

What this PR does / why we need it:

This PR addresses an attempt to split PVC handling between external-provisioner and sig-storage-lib-external-provisioner, also introducing a way to handle finalizers, related to in-progress PVC cloning.

PVC referenced in a data source is now updated with finalizer provisioner.storage.kubernetes.io/cloning-protectionr at the moment when a ProvisionExt method is called, used to dynamically provision a PV to which the content will be cloned at.

When cloning is finished - all PVC referencing the one as
a data source goes from Pending to Bound state, which allows the finalizer to be removed before deletion.

Which issue(s) this PR fixes:

Fixes #414

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

finalizers:
- provisioner.storage.kubernetes.io/cloning-protection

is now set on PVCs which are the source ones for the cloning,
preventing their removal before the cloning finishes.

@k8s-ci-robot k8s-ci-robot added 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. 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 11, 2020
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 11, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @Danil-Grigorev!

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 @Danil-Grigorev. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 11, 2020
@k8s-ci-robot k8s-ci-robot added 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 11, 2020
@Danil-Grigorev Danil-Grigorev changed the title [WIP] Added controller for PVC deletion Added controller for PVC deletion Mar 11, 2020
@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 Mar 11, 2020
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
@msau42
Copy link
Collaborator

msau42 commented Mar 11, 2020

/ok-to-test
/assign @jsafrane

@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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 11, 2020
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 12, 2020
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 13, 2020
"sigs.k8s.io/sig-storage-lib-external-provisioner/controller"
)

// CloningProtectionController struct
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment what the controller does - it prevents a PVC from being deleted while it's cloned.

run := func(context.Context) {
stopCh := context.Background().Done()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove stopCh?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accidentally left this change after seeing issues with a similar approach in tests, will undo this.

Comment on lines 88 to 93
pvcPhase(
pvcDataSourceClone(
pvcNamed(baseClaim(), dstName),
srcName,
),
v1.ClaimPending)},
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 more readable if you put claim as the last argument - function name + its arguments would be on the same line:

pvcPhase(v1.ClaimPending,
    pvcDataSourceClone(srcName,
        pvcNamed(dstName, baseClaim())

@@ -134,6 +134,8 @@ const (
annStorageProvisioner = "volume.beta.kubernetes.io/storage-provisioner"

snapshotNotBound = "snapshot %s not bound"

pvcCloneFinalizer = "external-provisioner.clone.kubernetes.io/finalizer"
Copy link
Contributor

Choose a reason for hiding this comment

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

provisioner.storage.kubernetes.io/cloning-protection

- Finalizer rename: 'external-provisioner.clone.kubernetes.io/finalizer' -> 'provisioner.storage.kubernetes.io/cloning-protection'
@jsafrane
Copy link
Contributor

Good work and thanks a lot!
/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Danil-Grigorev, jsafrane

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 16, 2020
@k8s-ci-robot k8s-ci-robot merged commit 59528e1 into kubernetes-csi:master Mar 16, 2020
@Danil-Grigorev Danil-Grigorev deleted the pvc-clone-finalizer branch March 16, 2020 17:29
}
p.claimInformer.AddEventHandlerWithResyncPeriod(claimHandler, controller.DefaultResyncPeriod)

for i := 0; i < threadiness; i++ {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is going to double the number of goroutines, and default value of worker-threads is 100 (so 200) total. Do we really need that many threads to process this finalizer? @jsafrane

Copy link
Contributor

Choose a reason for hiding this comment

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

hm, maybe not...

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'll address this in a follow up PR. Sorry for the issue. Could 5 be sufficient @msau42?

kbsonlong pushed a commit to kbsonlong/external-provisioner that referenced this pull request Dec 29, 2023
…go_modules/github.com/golang/protobuf-1.5.3

Bump github.com/golang/protobuf from 1.5.2 to 1.5.3
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Volume can be deleted in the middle of cloning
4 participants