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

Don't include excluded items in ItemBlocks #8572

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

sseago
Copy link
Collaborator

@sseago sseago commented Jan 2, 2025

Thank you for contributing to Velero!

Please add a summary of your change

Run itemExclusionChecks before adding items to ItemBlocks. Fixes a regression in 1.15 where excluding PVCs from backup no longer excludes associated PVs.

Does your change fix a particular issue?

Fixes #8510

Please indicate you've done the following:

@sseago
Copy link
Collaborator Author

sseago commented Jan 2, 2025

I haven't tested this locally yet. I need to rebuild my cluster tomorrow and then I'll test.

@Lyndon-Li
Copy link
Contributor

@sseago
Thanks for the quick fix. We are planning to create another quick patch 1.15.2 and this PR is included.
So hopefully this PR could be ready earlier next week, let us know if you need any help. Thanks.

@sseago sseago force-pushed the exclude-pvs-from-backup branch from defd3a4 to 533e8fb Compare January 3, 2025 20:25
Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 73.33333% with 8 lines in your changes missing coverage. Please review.

Project coverage is 59.17%. Comparing base (03d0bd9) to head (4b09b63).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
pkg/backup/backup.go 78.94% 3 Missing and 1 partial ⚠️
pkg/backup/itemblock.go 63.63% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8572   +/-   ##
=======================================
  Coverage   59.17%   59.17%           
=======================================
  Files         370      370           
  Lines       39568    39608   +40     
=======================================
+ Hits        23416    23440   +24     
- Misses      14673    14684   +11     
- Partials     1479     1484    +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sseago
Copy link
Collaborator Author

sseago commented Jan 3, 2025

@Lyndon-Li I was hoping to test the PR in a cluster environment today, but I ended up having to fix some problems with the PR (updated now) as well as rebuild my aws cluster. My plan is to test the PR on Monday, in the meantime it should be ready to review (but I want to do the testing on Monday before merging anything -- I want to make sure the change actually fixes the problem reported -- with PVC labeled for exclude but no labels on PV.

@Lyndon-Li
Copy link
Contributor

@Lyndon-Li I was hoping to test the PR in a cluster environment today, but I ended up having to fix some problems with the PR (updated now) as well as rebuild my aws cluster. My plan is to test the PR on Monday, in the meantime it should be ready to review (but I want to do the testing on Monday before merging anything -- I want to make sure the change actually fixes the problem reported -- with PVC labeled for exclude but no labels on PV.

Sure, we will start to review it, and will not merge it until you fully test it.

}
// Don't add to ItemBlock if item is excluded
// itemInclusionChecks logs the reason
if !b.itemBackupper.itemInclusionChecks(log, false, metadata, &unstructured, item.groupResource) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To me, it seems this change should already work.
It seems no need to add the same check in the pkg/backup/backup.go.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@blackpiglet When we add related items to the ItemBlock, we first attempt to find it in the list from the item collector -- in that case we already have the item content and don't need to make an APIServer call. That's the code path that adds to the ItemBlock here, so we need the inclusion check to skip excluded items.

In cases where the item is not already in the list of items from the item collector (PVs returned from PVC plugin when includeClusterResources==nil), then we have to pull the item via the APIServer -- that's the code path that makes the check in pkg/backup/backup.go

Note that this itemInclusionChecks call happens within itemblock.addKubernetesResource -- and whenever addKubernetesResource is called from backup.go, there's a continue call afterwards (line 613) , and the second itemInclusionChecks call is after this continue, so this check won't be performed twice.

@sseago sseago force-pushed the exclude-pvs-from-backup branch from 533e8fb to f41927d Compare January 6, 2025 23:07
Signed-off-by: Scott Seago <sseago@redhat.com>
@sseago sseago force-pushed the exclude-pvs-from-backup branch from f41927d to 4b09b63 Compare January 6, 2025 23:11
@sseago
Copy link
Collaborator Author

sseago commented Jan 6, 2025

@Lyndon-Li PR updated with feedback from @kaovilai and I was able to test it in an aws cluster environment today. Labeling the PVC but not the PV with the exclude label now properly excludes both PVC and PV from backup -- without this PR, I reproduced the bug found by the issue reporter.

@kaovilai kaovilai merged commit dce9777 into vmware-tanzu:main Jan 7, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After upgrade to 1.15, volumes are not excluded but PVC's are, with the exclude label set
5 participants