-
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
ItemSnapshotter Plugin APIs #4077
ItemSnapshotter Plugin APIs #4077
Conversation
8e3b6d6
to
0db329e
Compare
0db329e
to
20c9c41
Compare
20c9c41
to
078aadd
Compare
078aadd
to
baf5053
Compare
f7b2d6d
to
95b4fdf
Compare
return r | ||
} | ||
|
||
// getBackupItemAction returns the backup item action for this restartableBackupItemAction. It does *not* restart the |
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.
wrong comment
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.
Thanks
return itemSnapshotter, nil | ||
} | ||
|
||
// getDelegate restarts the plugin process (if needed) and returns the backup item action for this restartableBackupItemAction. |
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.
wrong comment
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.
Yup
ItemID velero.ResourceIdentifier | ||
// SnapshotID is the snapshot ID returned by ItemSnapshotter | ||
SnapshotID string | ||
// Backup is the representation of the restore resource processed by Velero. |
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.
restore resource -> backup resource
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.
Thanks
type SnapshotItemOutput struct { | ||
UpdatedItem runtime.Unstructured | ||
SnapshotID string | ||
SnapshotMetadata map[string]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.
could you give a concrete example of SnapshotMetadata
? This is not mentioned in the design and have you considered adding a GetSnapshot
method to return the detail information of the snapshot?
// which will be handled by this plugin when snapshotting the item. For example, a database may expose | ||
// a resource that can be snapshotted. If the database uses a PVC that will be snapshotted/backed up as | ||
// part of the database snapshot, that PVC should be returned when AlsoHandles is invoked | ||
AlsoHandles(input *AlsoHandlesInput) ([]velero.ResourceIdentifier, error) |
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.
This returns the same result as Additionalitems
in SnapshotItemOutput
?
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.
I updated the comment to explain:
// AlsoHandles is called for each item this ItemSnapshotter should handle and returns any items
// which will be handled by this plugin when snapshotting the item. These items will be excluded from the
// items being backed up. AlsoHandles will be called before SnapshotItem is called. For example, a database may expose
// a database resource that can be snapshotted. If the database uses a PVC that will be snapshotted/backed up as
// part of the database snapshot, that PVC should be returned when AlsoHandles is invoked. This is different from
// AdditionalItems (returned in SnapshotItemOutput and CreateItemOutput) which are specifying additional resources
// that Velero should store in the backup or create.
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.
I think we should be explicit in the comment here to explain if AlsoHandles
returns the direct children PEs only, or does it recursively traverse the subtree to return all leaf items.
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.
It will return everything that should be excluded from the caller's list of things to do. If Astrolabe is backing the ItemSnapshotter, the expectation is that it returns all of the PEs that will be snapshotted so they can be removed from the list. ItemSnapshotter is not limited to Astrolabe, however, and is not a Protected Entity interface here.
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.
So all children are handled in one call of SnapshotItem
, right? The resources returned by AlsoHandles
are only used to tell the caller to just ignore them
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.
Yes, that's the plan
type CreateItemInput struct { | ||
SnapshottedItem runtime.Unstructured | ||
SnapshotID string | ||
ItemFromBackup runtime.Unstructured |
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.
Could you add some comment to explain ItemFromBackup and SnapshotMetadata
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.
Done
if err != nil { | ||
return nil, errors.WithStack(err) | ||
} | ||
itemFromBackupJSOB, err := json.Marshal(input.ItemFromBackup.UnstructuredContent()) |
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.
itemFromBackupJSOB -> itemFromBackupJSON
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.
Thanks
// ProgressInput contains the input parameters for the ItemSnapshotter's Progress function. | ||
type ProgressInput struct { | ||
// ItemID is the id of item that was stored in the backup | ||
ItemID velero.ResourceIdentifier |
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.
I notice here's a little inconsistency, in SnapshotItemInput
the attribute is Item
but in ProgressInput
the attribute is ItemID
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.
When we snapshot we pass in the whole resource in case anything in it needs to be used. On progress we only need the ID and we may only have the ID at that point. If the Velero server is restarted before the progress is finished, we will lose the in-memory copy. The resource may be modified or deleted after the backup finishes so in order to pass in the resource here we would need to extract it from the backup. There's no need for anything other than the ID for checking progress so this saves a lot of trouble trying to recover the whole resource.
|
||
type DeleteSnapshotInput struct { | ||
SnapshotID string | ||
ItemFromBackup runtime.Unstructured |
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.
I don't quite understand why ItemFromBackup
is needed in the DeleteSnapshotInput, is it for cascade deletion?
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.
We take it in the existing DeleteItemAction, it is probably useful and we have it available.
// DeleteItemActionExecuteInput contains the input parameters for the ItemAction's Execute function. type DeleteItemActionExecuteInput struct { // Item is the item taken from the pristine backed up version of resource. Item runtime.Unstructured // Backup is the representation of the restore resource processed by Velero. Backup *velerov1api.Backup }
UpdatedItem runtime.Unstructured | ||
SnapshotID string | ||
SnapshotMetadata map[string]string // SnapshotMetadata is information in addition to the SnapshotID that the | ||
// plugin wants to store in the backup. SnapshotMetadata will be passed |
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.
The line of comments are not aligned, could you re-format?
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.
Done
|
||
type CreateItemInput struct { | ||
SnapshottedItem runtime.Unstructured // The snapshotted item at this stage of the restore (RestoreItemActions may | ||
// have modified the item prior to CreateItemFromSnapshot being called) |
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.
The lines of comments are not aligned, could you re-format?
SnapshottedItem runtime.Unstructured // The snapshotted item at this stage of the restore (RestoreItemActions may | ||
// have modified the item prior to CreateItemFromSnapshot being called) | ||
SnapshotID string | ||
ItemFromBackup runtime.Unstructured // The snapshotted item that was stored in the backup |
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.
Is this the "original version" of the SnapshottedItem
?
IMO, if an item is modified by RestoreItemActions
, the purpose is to let the subsequent plugins handle the modified version, otherwise, it should not be modified.
Is it for some corner cases that the two versions of an item is needed for ItemSnapshotterplugin to create the item from snapshot?
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.
It's useful to be able to see what it looked like before it got backed up. This is the same construct currently used in RestoreItemAction
// RestoreItemActionExecuteInput contains the input parameters for the ItemAction's Execute function. type RestoreItemActionExecuteInput struct { // Item is the item being restored. It is likely different from the pristine backed up version // (metadata reset, changed by various restore item action plugins, etc.). Item runtime.Unstructured // ItemFromBackup is the item taken from the pristine backed up version of resource. ItemFromBackup runtime.Unstructured // Restore is the representation of the restore resource processed by Velero. Restore *api.Restore }
Per discussion with Dave, some of the implementation of the input/output parameters to the API such as
maybe modified in the near future before it's established to other APP developers. |
01b8c63
to
7cbab01
Compare
// that Velero should store in the backup or create. | ||
AlsoHandles(input *AlsoHandlesInput) ([]velero.ResourceIdentifier, error) | ||
|
||
// SnapshotItem cause the ItemSnapshotter to snapshot the specified item. Ite may also |
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.
// SnapshotItem cause the ItemSnapshotter to snapshot the specified item. Ite may also | |
// SnapshotItem cause the ItemSnapshotter to snapshot the specified item. It may also |
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.
Thanks
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.
This looks good - I just have a few comments, mostly around the values set in the proto request/response objects. I don't know if they are intentionally not set or whether this is something that will be addressed in a follow up change.
Ah, I just read @reasonerjt's comment above and I'm assuming these are the parameters he's referring to. @dsu-igeek If that is the case, feel free to ignore/resolve my comments below about setting the fields in the requests and responses and I'll approve once the relevant copyright headers are added 👍 |
ece6665
to
fe5a799
Compare
Added ItemSnapshotter.proto Added item_snapshotter Go interface Added framework components for item_snapshotter Updated plugins doc with ItemSnapshotter info Added SnapshotPhase to item_snapshotter.go ProgressOutputOutput now includes a phase as well as an error string for problems that occured Signed-off-by: Dave Smith-Uchida <[email protected]>
fe5a799
to
9a6e0f2
Compare
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.
I still have some different thoughts on the details of the parameters to the functions of the interface.
Given we have the plan to tweak the parameters in near future before the API is published, I'm approving this PR to unblock the progress.
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.
LGTM, thanks!
Fixes #3754 |
…u#4077) Added ItemSnapshotter.proto Added item_snapshotter Go interface Added framework components for item_snapshotter Updated plugins doc with ItemSnapshotter info Added SnapshotPhase to item_snapshotter.go ProgressOutputOutput now includes a phase as well as an error string for problems that occured Signed-off-by: Dave Smith-Uchida <[email protected]>
…u#4077) Added ItemSnapshotter.proto Added item_snapshotter Go interface Added framework components for item_snapshotter Updated plugins doc with ItemSnapshotter info Added SnapshotPhase to item_snapshotter.go ProgressOutputOutput now includes a phase as well as an error string for problems that occured Signed-off-by: Dave Smith-Uchida <[email protected]>
…u#4077) Added ItemSnapshotter.proto Added item_snapshotter Go interface Added framework components for item_snapshotter Updated plugins doc with ItemSnapshotter info Added SnapshotPhase to item_snapshotter.go ProgressOutputOutput now includes a phase as well as an error string for problems that occured Signed-off-by: Dave Smith-Uchida <[email protected]>
…u#4077) Added ItemSnapshotter.proto Added item_snapshotter Go interface Added framework components for item_snapshotter Updated plugins doc with ItemSnapshotter info Added SnapshotPhase to item_snapshotter.go ProgressOutputOutput now includes a phase as well as an error string for problems that occured Signed-off-by: Dave Smith-Uchida <[email protected]>
ItemSnapshotter plugin APIs.
Added ItemSnapshotter.proto
Added item_snapshotter Go interface
Added framework components for item_snapshotter
Updated plugins doc with ItemSnapshotter info
Addresses #3754
Please indicate you've done the following:
/kind changelog-not-required
.site/content/docs/main
.