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 restore item action to update PVC selected-node annotation #2377

Merged
merged 3 commits into from
Apr 3, 2020

Conversation

mynktl
Copy link
Contributor

@mynktl mynktl commented Mar 30, 2020

This change solve below issue

If backed-up persistentvolumeclaims resource has an annotation of selected-node(volume.kubernetes.io/selected-node) and the given node doesn't exist in destination cluster, where the restore is triggered, then restore will stuck InProgress state.

Approach
This restoreItemAction works for persistentvolumeclaims resource having an annotation volume.kubernetes.io/selected-node.

If node-mapping for the given node exists in configMap(in velero installation namespace, with label selector velero.io/plugin-config,velero.io/change-pvc-node=RestoreItemAction), then the plugin will update the PVC annotation with new node and return the updated resource.

If node-mapping for the given node doesn't exist, then the plugin will check for the given node existence. If the given node doesn't exist in the cluster, then the plugin will delete the annotation for selected-node and return the updated persistentvolumeclaims resource.

Signed-off-by: mayank [email protected]

mayank added 2 commits March 30, 2020 15:47
@carlisia
Copy link
Contributor

carlisia commented Mar 31, 2020

For the core team: This seems to be the restore side of the same logical issue we are discussing on the backup side in this ticket #1878.

Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

thanks for the PR @mynktl! It looks pretty good, just a few small comments. Two further requests:

  • add a changelog (changelogs/unreleased/2377-mynktl) with a brief description of the change
  • update site/docs/master/restore-reference.md with info about this plugin - you can use the "Changing PV/PVC Storage Classes" section as a template

pkg/restore/change_pvc_node_selector.go Outdated Show resolved Hide resolved
pkg/restore/change_pvc_node_selector.go Outdated Show resolved Hide resolved
pkg/restore/change_pvc_node_selector.go Outdated Show resolved Hide resolved
@mynktl
Copy link
Contributor Author

mynktl commented Apr 3, 2020

Hi @skriss
Thanks for the review comments.
I've updated the PR with the changes you suggested. PTAL.

  • add a changelog (changelogs/unreleased/2377-mynktl) with a brief description of the change

  • update site/docs/master/restore-reference.md with info about this plugin - you can use the "Changing PV/PVC Storage Classes" section as a template

Thanks!

Copy link
Contributor

@skriss skriss left a comment

Choose a reason for hiding this comment

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

thanks for the updates @mynktl, LGTM! We'll just need one other reviewer.

Copy link
Contributor

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

👍 and thanks for the tests!

@carlisia carlisia merged commit 016868e into vmware-tanzu:master Apr 3, 2020
@mynktl mynktl requested a review from skriss April 5, 2020 10:34
@mynktl mynktl deleted the pvc_node_selector branch April 5, 2020 10:34
mynktl added a commit to mayadata-io/velero that referenced this pull request Apr 15, 2020
…e-tanzu#2377)

* New RestoreItemAction for PVC with annotation `volume.kubernetes.io/selected-node`

Signed-off-by: mayank <[email protected]>
@blackpiglet
Copy link
Contributor

blackpiglet commented May 23, 2022

According to my test on k8s v1.22, without this plugin, the restore can still work.
The logic in volume controller can remove the select-node annotation from PVC, if the node specified by annotation not found in the cluster, and reconcile for another try.

https://github.com/kubernetes/kubernetes/blob/release-1.16/pkg/controller/volume/persistentvolume/pv_controller.go#L1597-L1616

But I think this plugin's code still can be useful in some cases, of course, although it's not mandatory for restore to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants