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

Extend Volume Policies feature to support more actions #7664

Merged

Conversation

shubham-pampattiwar
Copy link
Collaborator

Thank you for contributing to Velero!

Please add a summary of your change

Implementation PR for Extend Volume Policies feature to support more actions

Related design: #6956

Does your change fix a particular issue?

Fixes #6640

Please indicate you've done the following:

  • Accepted the DCO. Commits without the DCO will delay acceptance.
  • Created a changelog file or added /kind changelog-not-required as a comment on this pull request.
  • Updated the corresponding documentation in site/content/docs/main.

continue
}
// don't backup volumes that are included in the exclude list.
if pdvolumeutil.Contains(volsToExclude, vol.Name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the condition pdvolumeutil.Contains in this line of code duplicated with the same logic in ShouldIncludeVolumeInBackup function? or it could not execute Line 129 for it will always execute L124 first if the matching condition?

Copy link
Contributor

Choose a reason for hiding this comment

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

@shubham-pampattiwar please take a look before merging this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Would it should be like below?

	for i, vol := range pod.Spec.Volumes {
		if !v.ShouldIncludeVolumeInBackup(vol, volsToExclude, backupExcludePVC) {
		       // don't backup volumes that are included in the exclude list.
		        if util.Contains(volsToExclude, vol.Name) {
			     FSBackupNonActionMatchingVols = append(FSBackupNonActionMatchingVols, vol.Name)
			     }
			continue
		}
		
		if vol.PersistentVolumeClaim != nil {}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually I have removed the volsToExclude check from the volume policy processing logic as it is related to legacy annotations based approach.
To Clarify, Volume Policy existence will be checked first and processed first. The legacy annotations based fallback option will be used only in 2 cases:

  • If no Volume Policy is specified by the user: Ref code link from PR
  • If there are Volumes for which no Volume Policy action was found i.e. action was nil : Ref code link from PR
    I have added comments in the code for the above process.

internal/volumehelper/volume_policy_helper.go Show resolved Hide resolved
internal/volumehelper/volume_policy_helper.go Show resolved Hide resolved
internal/volumehelper/volume_policy_helper.go Outdated Show resolved Hide resolved
pkg/backup/item_backupper.go Show resolved Hide resolved
internal/volumehelper/volume_policy_helper.go Outdated Show resolved Hide resolved
@Lyndon-Li
Copy link
Contributor

@shubham-pampattiwar Could help to address the comments so that we can further review and merge it? To meet FC, we hope this could be merged by the end of this week or early next week.

@shubham-pampattiwar shubham-pampattiwar force-pushed the vol-policy-extension-impl branch 2 times, most recently from 3961dbb to 10f1028 Compare April 20, 2024 07:56
@shubham-pampattiwar
Copy link
Collaborator Author

@Lyndon-Li addressed PR comments.

Copy link

codecov bot commented Apr 20, 2024

Codecov Report

Attention: Patch coverage is 73.85621% with 40 lines in your changes are missing coverage. Please review.

Project coverage is 58.66%. Comparing base (22b9465) to head (8d2bef2).
Report is 24 commits behind head on main.

Files Patch % Lines
pkg/backup/item_backupper.go 35.48% 16 Missing and 4 partials ⚠️
internal/volumehelper/volume_policy_helper.go 78.31% 11 Missing and 7 partials ⚠️
internal/resourcepolicies/resource_policies.go 75.00% 0 Missing and 1 partial ⚠️
pkg/cmd/server/server.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7664      +/-   ##
==========================================
+ Coverage   58.51%   58.66%   +0.14%     
==========================================
  Files         343      344       +1     
  Lines       28486    28723     +237     
==========================================
+ Hits        16670    16849     +179     
- Misses      10401    10445      +44     
- Partials     1415     1429      +14     

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

@Lyndon-Li
Copy link
Contributor

@shubham-pampattiwar
Two more following up comments from me and @blackpiglet, see if you could address it. Basically, we suggest to avoid generating a dynamic client inside the helper, but get it from the backup as an input parameter and then call the existing function in util/pvc_pv.go.

@Lyndon-Li
Copy link
Contributor

@shubham-pampattiwar
We also see the code coverage has dropped by 0.24% due to this PR, could you help to add some more test case?

@github-actions github-actions bot added the Dependencies Pull requests that update a dependency file label Apr 23, 2024
@shubham-pampattiwar shubham-pampattiwar force-pushed the vol-policy-extension-impl branch 3 times, most recently from fcff28b to b4a300f Compare April 23, 2024 00:16
@shubham-pampattiwar
Copy link
Collaborator Author

@Lyndon-Li @blackpiglet Addressed PR feedback and added tests. PTAL, Thanks !

Lyndon-Li
Lyndon-Li previously approved these changes Apr 23, 2024
blackpiglet
blackpiglet previously approved these changes Apr 23, 2024
@blackpiglet blackpiglet self-requested a review April 23, 2024 03:31
Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

fix volume policy action execution

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

remove unused files

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

add changelog file

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

fix CI linter errors

fix linter errors

address pr review comments

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

fix via make update cmd

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

address PR feedback and add tests

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

fix codespell

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

fix ci linter checks

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

remove volsToExclude processing from volume policy logic and add tests

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>

fix ci linter issue

Signed-off-by: Shubham Pampattiwar <spampatt@redhat.com>
@Lyndon-Li Lyndon-Li merged commit 01a2d95 into vmware-tanzu:main Apr 24, 2024
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dependencies Pull requests that update a dependency file has-changelog has-unit-tests target/FC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend VolumePolicies feature to support more actions other than just skip action
7 participants