Skip to content

Commit

Permalink
Restore progress reporting (vmware-tanzu#3125)
Browse files Browse the repository at this point in the history
* restore progress reporting

Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>

* add restore statistics to describe restore

Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>

* address feedback, include namespaces in the count

Signed-off-by: Pranav Gaikwad <pgaikwad@redhat.com>
  • Loading branch information
pranavgaikwad authored and gyaozhou committed May 14, 2022
1 parent d1edaa1 commit 2e34617
Show file tree
Hide file tree
Showing 11 changed files with 375 additions and 180 deletions.
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 @@ -58,6 +58,15 @@ func DescribeRestore(ctx context.Context, kbClient kbclient.Client, restore *vel
}

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

0 comments on commit 2e34617

Please sign in to comment.