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

[1.9.x] - Skip the exclusion check for additional resources returned by BIA #5406

Merged

Conversation

reasonerjt
Copy link
Contributor

@reasonerjt reasonerjt commented Sep 27, 2022

Introduce a simple contract so that BIA plugin developer can force the additional items be backed up

Signed-off-by: Daniel Jiang [email protected]

Thank you for contributing to Velero!

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.

Comment on lines +357 to +364
if _, ok := u.GetAnnotations()[mustIncludeAdditionalItemAnnotation]; ok {
delete(u.GetAnnotations(), mustIncludeAdditionalItemAnnotation)
}
Copy link
Member

Choose a reason for hiding this comment

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

This annotation looks good to me. Prevent errors.

@reasonerjt reasonerjt force-pushed the skip-additional-resources-poc-1.9 branch from 69a3010 to 2c657eb Compare September 28, 2022 00:29
Copy link
Collaborator

@sseago sseago left a comment

Choose a reason for hiding this comment

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

Looks good overall. One minor suggestion in the comments. Also, just to clarify at a high level -- the intent here is for a plugin to set the "must include" annotation on the modified resource for backup, not to add the annotation to the additional items in the cluster, right? That way the item backupper code can use the annotation and remove it before moving on to the next plugin, so this annotation never gets saved in the actual backup, since it's no longer needed.

@@ -341,12 +348,16 @@ func (ib *itemBackupper) executeActions(
return nil, errors.WithStack(err)
}

if _, err = ib.backupItem(log, item, gvr.GroupResource(), gvr); err != nil {
if _, err = ib.backupItem(log, item, gvr.GroupResource(), gvr,
u.GetAnnotations()[mustIncludeAdditionalItemAnnotation] == "true"); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than calling u.GetAnnotations() for each returned additional item, why not add this after line 324 above:

mustInclude := u..GetAnnotations()[mustIncludeAdditionalItemAnnotation] == "true")

and just use this bool var here to pass into backupItem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sseago Thanks.
The goal for this draft is to demonstrate the idea, if you are not against the idea, I will refine it and set it to ready for review.

if mustInclude {
log.Infof("Skipping the exclusion checks for this resource")
} else {
if metadata.GetLabels()["velero.io/exclude-from-backup"] == "true" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

NIT: convert the label key velero.io/exclude-from-backup to const ?

Copy link
Collaborator

@shubham-pampattiwar shubham-pampattiwar left a comment

Choose a reason for hiding this comment

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

Thank you @reasonerjt for the PR, the annotation approach makes sense, this will help solve the CSI plugin issues as well, just added a NIT, else LGTM!

@reasonerjt reasonerjt force-pushed the skip-additional-resources-poc-1.9 branch 2 times, most recently from 3f986af to 0bb456a Compare October 11, 2022 03:42
@reasonerjt reasonerjt marked this pull request as ready for review October 11, 2022 03:43
@reasonerjt reasonerjt changed the title Try to skip the exclusion check for additional resources returned by BIA Skip the exclusion check for additional resources returned by BIA Oct 11, 2022
@reasonerjt reasonerjt requested a review from ywk253100 October 11, 2022 03:45
@reasonerjt reasonerjt changed the title Skip the exclusion check for additional resources returned by BIA [1.9.x] - Skip the exclusion check for additional resources returned by BIA Oct 11, 2022
This commit provides a simple contract that if the BackupItemAction
plugin sets an annotation in a resource it has handled, the additional
items will considered "must include" i.e. each of them will skip the
"include-exclude" filter, such that the plugin developer can make sure
they are included in the backup disregarding the filter setting in the
bakcup CR.

Signed-off-by: Daniel Jiang <[email protected]>
Copy link
Collaborator

@sseago sseago left a comment

Choose a reason for hiding this comment

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

LGTM

@sseago sseago merged commit 59814d7 into vmware-tanzu:release-1.9 Oct 11, 2022
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.

5 participants