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

Restore progress reporting #3125

Merged
merged 3 commits into from Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/unreleased/3125-pranavgaikwad
@@ -0,0 +1 @@
Progress reporting added for Velero Restores
16 changes: 16 additions & 0 deletions config/crd/bases/velero.io_restores.yaml
Expand Up @@ -1651,6 +1651,22 @@ spec:
- PartiallyFailed
- Failed
type: string
progress:
description: Progress contains information about the restore's execution
progress. Note that this information is best-effort only -- if Velero
fails to update it during a restore for any reason, it may be inaccurate/stale.
nullable: true
properties:
itemsRestored:
description: ItemsRestored is the number of items that have actually
been restored so far
type: integer
totalItems:
description: TotalItems is the total number of items to be restored.
This number may change throughout the execution of the restore
due to plugins that return additional related items to restore
type: integer
type: object
startTimestamp:
description: StartTimestamp records the time the restore operation was
started. The server's time is used for StartTimestamps
Expand Down
2 changes: 1 addition & 1 deletion config/crd/crds/crds.go

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions pkg/apis/velero/v1/restore.go
Expand Up @@ -252,6 +252,25 @@ type RestoreStatus struct {
// +optional
// +nullable
CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"`

// Progress contains information about the restore's execution progress. Note
// that this information is best-effort only -- if Velero fails to update it
// during a restore for any reason, it may be inaccurate/stale.
// +optional
// +nullable
Progress *RestoreProgress `json:"progress,omitempty"`
}

// RestoreProgress stores information about the restore's execution progress
type RestoreProgress struct {
// TotalItems is the total number of items to be restored. This number may change
// throughout the execution of the restore due to plugins that return additional related
// items to restore
// +optional
TotalItems int `json:"totalItems,omitempty"`
// ItemsRestored is the number of items that have actually been restored so far
// +optional
ItemsRestored int `json:"itemsRestored,omitempty"`
}

// +genclient
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/velero/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/cmd/server/server.go
Expand Up @@ -679,6 +679,7 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string

restoreControllerRunInfo := func() controllerRunInfo {
restorer, err := restore.NewKubernetesRestorer(
s.veleroClient.VeleroV1(),
s.discoveryHelper,
client.NewDynamicFactory(s.dynamicClient),
s.config.restoreResourcePriorities,
Expand Down
9 changes: 9 additions & 0 deletions pkg/cmd/util/output/restore_describer.go
Expand Up @@ -56,6 +56,15 @@ func DescribeRestore(restore *v1.Restore, podVolumeRestores []v1.PodVolumeRestor
}

d.Printf("Phase:\t%s%s\n", phaseString, resultsNote)
if restore.Status.Progress != nil {
if restore.Status.Phase == v1.RestorePhaseInProgress {
d.Printf("Estimated total items to be restored:\t%d\n", restore.Status.Progress.TotalItems)
d.Printf("Items restored so far:\t%d\n", restore.Status.Progress.ItemsRestored)
} else {
d.Printf("Total items to be restored:\t%d\n", restore.Status.Progress.TotalItems)
d.Printf("Items restored:\t%d\n", restore.Status.Progress.ItemsRestored)
}
}

d.Println()
// "<n/a>" output should only be applicable for restore that failed validation
Expand Down