Skip to content

Always Start pvc-protection-controller#61282

Closed
pospispa wants to merge 1 commit intokubernetes:release-1.9from
pospispa:60764-K8s-1.9-PVC-protection-downgrade-issue
Closed

Always Start pvc-protection-controller#61282
pospispa wants to merge 1 commit intokubernetes:release-1.9from
pospispa:60764-K8s-1.9-PVC-protection-downgrade-issue

Conversation

@pospispa
Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
After K8s 1.9 is upgraded to K8s 1.10 finalizer [kubernetes.io/pvc-protection] is added to PVCs
because StorageObjectInUseProtection feature is enabled by default in K8s 1.10.
However, when K8s 1.10 is downgraded to K8s 1.9 the finalizers remain in the PVCs and as pvc-protection-controller is not started by default in K8s 1.9 finalizers are not removed automatically from deleted PVCs and that's why deleted PVC are not removed but remain in Terminating phase.

That's why pvc-protection-controller is always started because the pvc-protection-controller removes finalizers from PVCs automatically when a PVC is not in active use by a pod.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #60764

Special notes for your reviewer:
This PR fixes problem with finalizers in PVCs only. It does not fix problem with finalizers in PVs.

Release note:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 16, 2018
@k8s-ci-robot k8s-ci-robot requested review from deads2k and sttts March 16, 2018 15:32
@k8s-github-robot k8s-github-robot added the do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. label Mar 16, 2018
@pospispa
Copy link
Copy Markdown
Contributor Author

@rootfs @saad-ali PTAL

@pospispa pospispa force-pushed the 60764-K8s-1.9-PVC-protection-downgrade-issue branch from 03c3671 to d61a1e1 Compare March 16, 2018 17:00
@saad-ali
Copy link
Copy Markdown
Member

Couple of comments:

  1. Does this PR only enable the "remove finalizer" component or does it enable both "remove finalizer" and "add finalizer" (we want to add only if alpha flag is set)?
  2. Does this work for both PV/PVC and Pod/PVC? I thought one of these did not exist in 1.9?

@pospispa
Copy link
Copy Markdown
Contributor Author

  1. Does this PR only enable the "remove finalizer" component or does it enable both "remove finalizer" and "add finalizer" (we want to add only if alpha flag is set)?

It allows both adding and removing finalizers. I forgot to feature flag the adding of finalizers.

  1. Does this work for both PV/PVC and Pod/PVC? I thought one of these did not exist in 1.9?

It works only for Pod/PVC. It doesn't work for PV/PVC.

@jdumars
Copy link
Copy Markdown
Contributor

jdumars commented Mar 16, 2018

@jpbetz PTAL - this needs to get in ASAP so we can validate test signal.

@jpbetz jpbetz added lgtm "Looks good to me", indicates that a PR is ready to be merged. cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. approved Indicates a PR has been approved by an approver from all required OWNERS files. status/approved-for-milestone priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. and removed do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. labels Mar 16, 2018
@pospispa
Copy link
Copy Markdown
Contributor Author

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 16, 2018
@calebamiles
Copy link
Copy Markdown
Contributor

calebamiles commented Mar 16, 2018

@pospispa would you mind commenting on the hold for this PR for the release team. Thanks!

cc: @jdumars, @saad-ali, @kubernetes/kubernetes-release-managers

@pospispa
Copy link
Copy Markdown
Contributor Author

In case the PVCProtection feature is not enabled the pvc-protection-controller is adding finalizers to PVCs, but it must be in finalizer removal only mode, therefore
/hold

@pospispa pospispa force-pushed the 60764-K8s-1.9-PVC-protection-downgrade-issue branch from d61a1e1 to 4b0ae05 Compare March 16, 2018 18:10
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 16, 2018
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by: pospispa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@pospispa
Copy link
Copy Markdown
Contributor Author

I updated the PR so that in case the PVCProtection feature is not enabled the pvc-protection-controller does not add finalizers to PVCs, but it only removes finalizers, therefore
/hold cancel

@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 16, 2018
@pospispa
Copy link
Copy Markdown
Contributor Author

@saad-ali @jpbetz @calebamiles @rootfs @jdumars this PR is ready for review.

IMPORTANT: this PR contains only the Pod/PVC part, i.e. finalizers are automatically removed only from PVCs not PVs.

@pospispa pospispa force-pushed the 60764-K8s-1.9-PVC-protection-downgrade-issue branch from 4b0ae05 to f40fe59 Compare March 16, 2018 18:17
@pospispa pospispa force-pushed the 60764-K8s-1.9-PVC-protection-downgrade-issue branch from f40fe59 to 8cfc579 Compare March 16, 2018 19:19
@liggitt
Copy link
Copy Markdown
Member

liggitt commented Mar 16, 2018

when this completes review, #61299 can be reverted as part of this as well

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Mar 16, 2018

the finalizers on PV objects must be removed as well (e.g. partial backport of #58743)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

setting global feature gates in unit tests is racy... consider passing a feature gate to the controller and checking the local one rather than mutating global state here (and leaving it mutated after the unit test runs).

See https://github.com/kubernetes/kubernetes/blob/master/plugin/pkg/auth/authorizer/node/node_authorizer.go#L53 as an example

After K8s 1.9 is upgraded to K8s 1.10 finalizer [kubernetes.io/pvc-protection] is added to PVCs
because StorageObjectInUseProtection feature is enabled by default in K8s 1.10.
However, when K8s 1.10 is downgraded to K8s 1.9 the finalizers remain in the PVCs and as pvc-protection-controller
is not started by default in K8s 1.9 finalizers are not removed automatically from deleted PVCs and that's why
deleted PVC are not removed but remain in Terminating phase.

That's why pvc-protection-controller is always started because the pvc-protection-controller removes finalizers
from PVCs automatically when a PVC is not in active use by a pod.

Related issue: kubernetes#60764
@pospispa pospispa force-pushed the 60764-K8s-1.9-PVC-protection-downgrade-issue branch from 8cfc579 to 213c8b4 Compare March 17, 2018 12:04
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 17, 2018
@pospispa
Copy link
Copy Markdown
Contributor Author

the finalizers on PV objects must be removed as well (e.g. partial backport of #58743)

@liggitt I believe that if I split finalizer removal from PVCs and PVs into 2 separate PRs that it'll simplify the reviews. That's why I plan to create a new separate PR for the PV finalizer removal.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Mar 17, 2018

That's fine, just wanted to make sure it was clear that this PR wasn't the extent of the changes needed in 1.9

@pospispa
Copy link
Copy Markdown
Contributor Author

@liggitt I believe I've addressed all your comments. PTAL. Would you LGTM?

@pospispa
Copy link
Copy Markdown
Contributor Author

the finalizers on PV objects must be removed as well (e.g. partial backport of #58743)

@liggitt I've created PR #61316 that removes finalizers from PVs.

@jpbetz
Copy link
Copy Markdown
Contributor

jpbetz commented Mar 18, 2018

/hold
Hold all unmerged cherrypicks for cut of patch release on Monday.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 18, 2018
}

func (c *Controller) addFinalizer(pvc *v1.PersistentVolumeClaim) error {
// Skip adding Finalizer in case the PVC Protection feature is not enabled
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think I am missing something but which bits will by default remove the finalizer if feature gate is disabled? I do not see that in the code.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think what we need to add is - when feature gate is disabled then we need to return false by default from isBeingUsed function so as controller can run in "remove finalizer" only mode. As it exists - this code will not remove the finalizer from PVCs which are in use by pods, even if feature gate is disabled.

@gnufied
Copy link
Copy Markdown
Member

gnufied commented Mar 19, 2018

@liggitt @pospispa @saad-ali I am not sure that controller change introduced in #61282 and #61316 is enough. We are still left with the problem that - if user upgrades to 1.10 and then downgrades to 1.9 (with aforementioned controller fixes), he can't delete the PVCs until he "touches" the PVCs in some manner because controller will only remove finalizer if it notices add/update event on PVC. We may have to introduce some sort of additional loop that removes finalizers from existing PVC objects, even if they aren't updated.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Mar 19, 2018

We are still left with the problem that - if user upgrades to 1.10 and then downgrades to 1.9 (with aforementioned controller fixes), he can't delete the PVCs until he "touches" the PVCs in some manner because controller will only remove finalizer if it notices add/update event on PVC.

No. On startup, every informer gets an Add event for every existing object.

@liggitt
Copy link
Copy Markdown
Member

liggitt commented Mar 19, 2018

Also, the delete that sets the deletionTimestamp (but leaves the record in place until all finalizers are removed) would trigger an Update watch event

@jpbetz jpbetz removed the cherry-pick-approved Indicates a cherry-pick PR into a release branch has been approved by the release branch manager. label Mar 20, 2018
@k8s-github-robot k8s-github-robot added the do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. label Mar 20, 2018
@k8s-github-robot
Copy link
Copy Markdown

This PR is not for the master branch but does not have the cherrypick-approved label. Adding the do-not-merge/cherry-pick-not-approved label.

@pospispa
Copy link
Copy Markdown
Contributor Author

Replaced by PR #61370 so I'm closing this PR.

@pospispa pospispa closed this Mar 20, 2018
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. do-not-merge/cherry-pick-not-approved Indicates that a PR is not yet approved to merge into a release branch. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. priority/critical-urgent Highest priority. Must be actively worked on as someone's top priority right now. release-note-none Denotes a PR that doesn't merit a release note. 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.

9 participants