Skip to content

Commit

Permalink
Wait for additional items to be ready before restoring current item
Browse files Browse the repository at this point in the history
Signed-off-by: Scott Seago <sseago@redhat.com>
  • Loading branch information
sseago committed Mar 13, 2023
1 parent 36163c9 commit a2621ca
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 71 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/5933-sseago
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wait for additional items to be ready before restoring current item
11 changes: 8 additions & 3 deletions pkg/restore/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,24 @@ type Request struct {
PodVolumeBackups []*velerov1api.PodVolumeBackup
VolumeSnapshots []*volume.Snapshot
BackupReader io.Reader
RestoredItems map[itemKey]string
RestoredItems map[itemKey]restoredItemStatus
}

type restoredItemStatus struct {
action string
itemExists bool
}

// RestoredResourceList returns the list of restored resources grouped by the API
// Version and Kind
func (r *Request) RestoredResourceList() map[string][]string {
resources := map[string][]string{}
for i, action := range r.RestoredItems {
for i, item := range r.RestoredItems {
entry := i.name
if i.namespace != "" {
entry = fmt.Sprintf("%s/%s", i.namespace, i.name)
}
entry = fmt.Sprintf("%s(%s)", entry, action)
entry = fmt.Sprintf("%s(%s)", entry, item.action)
resources[i.resource] = append(resources[i.resource], entry)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/restore/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ func TestResourceKey(t *testing.T) {

func TestRestoredResourceList(t *testing.T) {
request := &Request{
RestoredItems: map[itemKey]string{
RestoredItems: map[itemKey]restoredItemStatus{
{
resource: "v1/Namespace",
namespace: "",
name: "default",
}: "created",
}: {action: "created"},
{
resource: "v1/ConfigMap",
namespace: "default",
name: "cm",
}: "skipped",
}: {action: "skipped"},
},
}

Expand Down
Loading

0 comments on commit a2621ca

Please sign in to comment.