Skip to content

Commit

Permalink
Skip updating status when CRDs are restored
Browse files Browse the repository at this point in the history
This commit skips updating the restore progress, in the first loop for
restoration when CRDs are handled, so that the misleading "totalItem"
will not appear in the CR.
Fixes #5990

Signed-off-by: Daniel Jiang <[email protected]>
  • Loading branch information
reasonerjt committed May 30, 2023
1 parent 9467d7c commit 89d5d6a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/6325-reasonerjt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Skip updating status when CRDs are restored
13 changes: 8 additions & 5 deletions pkg/restore/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,14 @@ func (ctx *restoreContext) execute() (results.Result, results.Result) {

for _, selectedResource := range crdResourceCollection {
var w, e results.Result
// Restore this resource
// Restore this resource, the update channel is set to nil, to avoid misleading value of "totalItems"
// more details see #5990
processedItems, w, e = ctx.processSelectedResource(
selectedResource,
totalItems,
processedItems,
existingNamespaces,
update,
nil,
)
warnings.Merge(&w)
errs.Merge(&e)
Expand Down Expand Up @@ -661,9 +662,11 @@ func (ctx *restoreContext) processSelectedResource(
// time, we don't want previously known items counted twice as
// they are present in both restoredItems and totalItems.
actualTotalItems := len(ctx.restoredItems) + (totalItems - processedItems)
update <- progressUpdate{
totalItems: actualTotalItems,
itemsRestored: len(ctx.restoredItems),
if update != nil {
update <- progressUpdate{
totalItems: actualTotalItems,
itemsRestored: len(ctx.restoredItems),
}
}
ctx.log.WithFields(map[string]interface{}{
"progress": "",
Expand Down

0 comments on commit 89d5d6a

Please sign in to comment.