-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Skip PVB creation when PVC excluded #7045
Skip PVB creation when PVC excluded #7045
Conversation
afd8a84
to
2cb4334
Compare
@sbahar619 Also, see the CI/linter check failures -- looks like whitespace issues to fix via "make update", etc. And you need a changelog entry: https://velero.io/docs/main/code-standards/#adding-a-changelog |
2cb4334
to
2483648
Compare
Thanks, I added changelogs file, I will fix the lint issue. |
2483648
to
e6b3438
Compare
@sbahar619 I found a problem with a couple of the unit tests -- they weren't including PVCs in the backup but were expecting PVBs, so that's no longer going to work with this change. I submitted a PR against your PR branch -- if you merge that, it will be added to this PR: sbahar619#1 |
Thanks! |
@sbahar619 please sign your commit and squash them. |
Signed-off-by: Shahaf Bahar <[email protected]>
e5f6693
to
23fbc19
Compare
Done @shubham-pampattiwar , thanks. |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #7045 +/- ##
==========================================
- Coverage 61.03% 61.00% -0.04%
==========================================
Files 252 255 +3
Lines 26900 27048 +148
==========================================
+ Hits 16419 16501 +82
- Misses 9319 9367 +48
- Partials 1162 1180 +18 ☔ View full report in Codecov by Sentry. |
@qiuming-best |
There is still some discussion about whether this logic should be added. The concern is when the pod's volumes are specified to back up by file-system upload, but the PVC is excluded, which rule should have a higher priority. The current way is not to miss the PVC volume backup. |
@blackpiglet |
"The concern is when the pod's volumes are specified to back up by file-system upload, but the PVC is excluded, which rule should have a higher priority." Hmm, I don't think that's really an issue. The "fs vs. snapshot" decision determines how a volume is backed up. In the case handled by this PR, all PVCs are excluded (i.e. they're excluded resources), which means a PVB for this PVC can never be restored because the volume won't be found when restoring the backup. This results in a problematic user workflow:
@sbahar619 What was the error you got in this case without the PR fix? |
@sseago |
@sbahar619 @blackpiglet hmm. Another possible resolution would be to only warn instead of fail if an additional item is not found in the backup at restore time. Unclear whether that's any better, as there may be cases where we want missing additional items to error out. |
@sbahar619 @sseago |
The issue is that currently, if you try to run a FS backup with excluded PVC, the PVB will still be created (which I disabled in this PR because it is not expected) for all the PVCs, but in the end, the PVC resource itself is really not backed up because of the excluded PVC which is expected, this backup is completed successfully, so what happens is that when you run a restore using this same backup, it will fail complaining it's not finding any PVCs, because the restore here is triggering PVR, which is again not expected. |
@shobha2626 Out of curiosity, will the restore be completed successfully with this PR? |
Currently, if you run a FS backup with PVC excluded, the PVB will still be created, and backup the data, which is not expected. And yes, I verified this PR, if you run backup using this PR fix, backup and restore will completed successfully and fully skip the PVC. |
Could you share your backed-up workload's YAML? |
Sure, here is a backup yaml:
After the backup, I deleted the NS application and the PVCs, then tried restore. |
As we have reached the FC v1.13 and this makes break change to current behavior, I'm blocking this PR from merging to main, until we cut the release branch for v1.13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revisit this PR after the release branch is cut
@sbahar619
|
This is expected, because we asked to exclude PVC in backup so restore have no PVC, pod manifest still request PVC volume so pod will be pending and not starting. |
@sbahar619 |
I don't think it's a common scenario, but the behavior of Velero is more accurate with this PR. |
I see. If we can have a mechanism to resolve the backed-up resource dependency, that would be an ideal way, but there is probably no available solution in the short term. |
@shubham-pampattiwar please review as you have time. |
@blackpiglet Note that the "pod is pending" is probably what you'll see without this PR if you're not using fs-backup, since that's a function of the user choosing to exclude PVC while including pods. I think the restore error obscures what's going on a bit. I suspect that this PR brings fs backup use case inline with what we already see for datamover or snapshot backups. |
@sseago |
There are two issues involved:
I think the opinion on number 2 will impact how we handle number 1. I'm more inclined to let velero do what the user tells it to, i.e. it should exclude the PVC even if it will certainly fail the pod after restore. |
Regarding 1) "When the PVC is excluded, the PVB should not be created. This is not consistent with how we handle CSI snapshots." -- Actually, this is consistent with CSI. If the PVC is excluded, then we don't back it up. If we don't back it up, then the BIA for the PVC doesn't run. If the BIA doesn't run, we don't create the VolumeSnapshot. Regarding 2) "When a backup excludes all PVC, any pods that have PVC mounted will not be restored successfully." This is also true for snapshot restores. Velero reports a successful restore -- the Pod object was successfully restored, but the pod will be pending until the PVC is created. One reason a user may want to omit PVCs from the backup is because they're backing them up via some other means -- in that case, that other means will need to restore them as well. If I'm understanding points 1) and 2) above correctly, skipping PVB creation makes FS backup/restore consistent with CSI and Volume Snapshotter backup/restore behavior. The end result is (currently for snapshots, proposed in this PR for FS backup) is as follows:
At the most basic level, if a user is excluding PVCs from backup, then velero shouldn't waste time copying PVC contents into the BSL, whether via datamover or via FS backup. |
@sbahar619 |
Hi @blackpiglet |
for _, volume := range includedVolumes { | ||
// Check if the PVC resource is not included in the backup | ||
if !ib.backupRequest.ResourceIncludesExcludes.ShouldInclude(kuberesource.PersistentVolumeClaims.String()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should move this check into a more proper function, e.g. GetVolumesByPod.
@sbahar619 |
Hi @sbahar619, are you still working on this? |
Hi @blackpiglet , sorry for the delay! |
Because #7472 addressed the need in this PR, close this PR. |
Please add a summary of your change
FS backup create PodVolumeBackup when the backup excluded PVC, so I added logic to skip PVC volume type when PVC is not included in the backup resources to be backed up.
Does your change fix a particular issue?
Fixes #(issue)
Please indicate you've done the following:
/kind changelog-not-required
as a comment on this pull request.site/content/docs/main
.