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

BackupItemAction v2 API implementation #5442

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

sseago
Copy link
Collaborator

@sseago sseago commented Oct 12, 2022

Signed-off-by: Scott Seago [email protected]

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #5488

Please indicate you've done the following:

  • [x ] Accepted the DCO. Commits without the DCO will delay acceptance.
  • [x ] 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.

@codecov-commenter
Copy link

codecov-commenter commented Oct 12, 2022

Codecov Report

Merging #5442 (ff748cc) into main (c0430b8) will decrease coverage by 0.19%.
The diff coverage is 31.64%.

@@            Coverage Diff             @@
##             main    #5442      +/-   ##
==========================================
- Coverage   40.62%   40.43%   -0.20%     
==========================================
  Files         236      240       +4     
  Lines       20449    20826     +377     
==========================================
+ Hits         8308     8421     +113     
- Misses      11532    11790     +258     
- Partials      609      615       +6     
Impacted Files Coverage Δ
pkg/backup/request.go 100.00% <ø> (ø)
pkg/plugin/framework/action_resolver.go 5.75% <0.00%> (-1.15%) ⬇️
...ramework/backupitemaction/v2/backup_item_action.go 0.00% <0.00%> (ø)
...k/backupitemaction/v2/backup_item_action_client.go 0.00% <0.00%> (ø)
pkg/plugin/framework/common/plugin_kinds.go 0.00% <0.00%> (ø)
pkg/plugin/framework/server.go 0.00% <0.00%> (ø)
...k/backupitemaction/v2/backup_item_action_server.go 33.06% <33.06%> (ø)
...kupitemaction/v2/restartable_backup_item_action.go 65.21% <65.21%> (ø)
pkg/plugin/clientmgmt/manager.go 78.92% <88.88%> (+1.52%) ⬆️
pkg/backup/backup.go 78.88% <100.00%> (ø)
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@kaovilai
Copy link
Member

This PR closes #5488

@weshayutin
Copy link
Contributor

weshayutin commented Dec 13, 2022

my very newb scan of this leaves me w/ just a thought and I don't have a strong opinion here.
Thank you for updating the unit tests and labeling the overriden api tests w/ V2. Would it help the reader of the unit tests results to name the item w/ a V2 as well even though there is NOT a V1? e.g. NewBackupItemActionPlugin -> NewBackupItemActionPluginV2

@sseago
Copy link
Collaborator Author

sseago commented Dec 13, 2022

@weshayutin I'm not seeing any funcs named NewBackupItemActionPlugin in the test files. Where I see a function of this name in the other code, it's in a package that identifies it as v1 vs. v2. Was there some test in particular that you were referencing?

@github-actions github-actions bot added the Area/Design Design Documents label Dec 13, 2022
@sseago sseago marked this pull request as ready for review December 13, 2022 19:58
updatedItem, additionalItemIdentifiers, err := action.Execute(obj, ib.backupRequest.Backup)
// Note: we're ignoring the operationID returned from Execute for now, it will be used
// with the async plugin action implementation
updatedItem, additionalItemIdentifiers, _, err := action.Execute(obj, ib.backupRequest.Backup)
Copy link
Contributor

@Lyndon-Li Lyndon-Li Jan 3, 2023

Choose a reason for hiding this comment

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

After the Execute method is called, the method may return in a short time but the async operation is still ongoing.
As to the backup workflow, I guess the caller needs to call the Progress method to wait the completion of the async operation.
For different items in the same backup, multiple Execute methods may be called successively before their async operations complete, so before the backup workflow ends, multiple async operations should be waited for completion.

Will we handle this logic in the current PR or we do it in later PRs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Lyndon-Li This PR is just the API definition. It adds the appropriate functions to the various BackupItemAction-related packages. Implmeenting the controller workflow changes to actually call Progress, wait, maintain a list of items waited for, etc. will be implemented in a separate PR (there's a separate github issue to track that work).

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 @sseago

biav2 "github.com/vmware-tanzu/velero/pkg/plugin/velero/backupitemaction/v2"
)

// AdaptedBackupItemAction is a backup item action adapted to the v1 BackupItemAction API
Copy link
Contributor

Choose a reason for hiding this comment

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

v1->v2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll reword it to make it clearer. "is a v1 BackupItemAction adapted to implement the v2 API"

}

// Execute restarts the plugin's process if needed, then delegates the call.
func (r *RestartableBackupItemAction) Execute(item runtime.Unstructured, backup *api.Backup) (runtime.Unstructured, []velero.ResourceIdentifier, string, error) {
Copy link
Contributor

@Lyndon-Li Lyndon-Li Jan 3, 2023

Choose a reason for hiding this comment

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

Thinking of some plugin process restart cases:

  1. If the plugin process quits unexpectedly (i.e. crash) during a method calling, the call will fail on the client side, so the backup/restore will fail because of the BIA/RIA method fails. Is that right?
  2. Since the plugin runs some async operations, the plugin may quit outside a method calling, for example, the Execute method returns successfully but during running the async operation afterwards, the plugin crashes. In this case, I think the client side gets no notification from the plugin framework, but the specific BIA/RIA implementation needs to tell the caller during the later method calling (i.e., Progress method) if it wants to fail the current backup/restore? Or if we want the plugin implementation has the ability to recover from the quit, what is it like?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Lyndon-Li

  1. It should result in a partial failure, as the GRPC call itself will error out, but that's not any different from what happens with v1 plugins
  2. If the plugin crashes without restarting, then the Progress method will return an error (similar to the Execute error in your first question), so this will push us to partial failure. If the plugin crashes but restarts, then it's up to the plugin to handle this. For example, for a datamover plugin which creates a separate datamover CR (where the actual async operation happens in a separate controller), a plugin restart after creating the datamover CR won't affect progress, as long as the plugin is running again by the time velero calls Progress next, since it just checks the datamover CR status. If the plugin is itself running the operation in a background thread of the plugin process, then a crash will probably result in an operation failure, so Progress will return an error.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, either way is allowed, the behavior is up to the specific plugin.

@shubham-pampattiwar
Copy link
Collaborator

LGTM ! Thank you @sseago

@shubham-pampattiwar shubham-pampattiwar merged commit ab642ff into vmware-tanzu:main Jan 10, 2023
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.

Implement new plugin v2 APIs for BackupItemAction
6 participants