mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-06 05:25:40 +00:00
Merge pull request #9368 from shubham-pampattiwar/fix-volume-info-generatename
Some checks failed
Run the E2E test on kind / get-go-version (push) Failing after 1m21s
Run the E2E test on kind / build (push) Has been skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / get-go-version (push) Failing after 15s
Main CI / Build (push) Has been skipped
Close stale issues and PRs / stale (push) Successful in 11s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 3m52s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m6s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 57s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m4s
Some checks failed
Run the E2E test on kind / get-go-version (push) Failing after 1m21s
Run the E2E test on kind / build (push) Has been skipped
Run the E2E test on kind / setup-test-matrix (push) Successful in 3s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / get-go-version (push) Failing after 15s
Main CI / Build (push) Has been skipped
Close stale issues and PRs / stale (push) Successful in 11s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 3m52s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m6s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 57s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m4s
Track actual resource names for GenerateName in restore status
This commit is contained in:
1
changelogs/unreleased/9368-shubham-pampattiwar
Normal file
1
changelogs/unreleased/9368-shubham-pampattiwar
Normal file
@@ -0,0 +1 @@
|
||||
Track actual resource names for GenerateName in restore status
|
||||
@@ -69,8 +69,9 @@ type Request struct {
|
||||
}
|
||||
|
||||
type restoredItemStatus struct {
|
||||
action string
|
||||
itemExists bool
|
||||
action string
|
||||
itemExists bool
|
||||
createdName string // Actual name assigned by K8s for GenerateName resources
|
||||
}
|
||||
|
||||
// GetItemOperationsList returns ItemOperationsList, initializing it if necessary
|
||||
@@ -87,9 +88,15 @@ func (r *Request) GetItemOperationsList() *[]*itemoperation.RestoreOperation {
|
||||
func (r *Request) RestoredResourceList() map[string][]string {
|
||||
resources := map[string][]string{}
|
||||
for i, item := range r.RestoredItems {
|
||||
entry := i.name
|
||||
// Use createdName if available (GenerateName case), otherwise itemKey.name
|
||||
name := i.name
|
||||
if item.createdName != "" {
|
||||
name = item.createdName
|
||||
}
|
||||
|
||||
entry := name
|
||||
if i.namespace != "" {
|
||||
entry = fmt.Sprintf("%s/%s", i.namespace, i.name)
|
||||
entry = fmt.Sprintf("%s/%s", i.namespace, name)
|
||||
}
|
||||
entry = fmt.Sprintf("%s(%s)", entry, item.action)
|
||||
resources[i.resource] = append(resources[i.resource], entry)
|
||||
|
||||
@@ -741,7 +741,7 @@ func (ctx *restoreContext) processSelectedResource(
|
||||
namespace: ns.Namespace,
|
||||
name: ns.Name,
|
||||
}
|
||||
ctx.restoredItems[itemKey] = restoredItemStatus{action: ItemRestoreResultCreated, itemExists: true}
|
||||
ctx.restoredItems[itemKey] = restoredItemStatus{action: ItemRestoreResultCreated, itemExists: true, createdName: ns.Name}
|
||||
}
|
||||
|
||||
// Keep track of namespaces that we know exist so we don't
|
||||
@@ -1142,7 +1142,7 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
|
||||
namespace: nsToEnsure.Namespace,
|
||||
name: nsToEnsure.Name,
|
||||
}
|
||||
ctx.restoredItems[itemKey] = restoredItemStatus{action: ItemRestoreResultCreated, itemExists: true}
|
||||
ctx.restoredItems[itemKey] = restoredItemStatus{action: ItemRestoreResultCreated, itemExists: true, createdName: nsToEnsure.Name}
|
||||
}
|
||||
} else {
|
||||
if boolptr.IsSetToFalse(ctx.restore.Spec.IncludeClusterResources) {
|
||||
@@ -1514,7 +1514,11 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
|
||||
createdObj, restoreErr = resourceClient.Create(obj)
|
||||
if restoreErr == nil {
|
||||
itemExists = true
|
||||
ctx.restoredItems[itemKey] = restoredItemStatus{action: ItemRestoreResultCreated, itemExists: itemExists}
|
||||
ctx.restoredItems[itemKey] = restoredItemStatus{
|
||||
action: ItemRestoreResultCreated,
|
||||
itemExists: itemExists,
|
||||
createdName: createdObj.GetName(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1091,8 +1091,8 @@ func TestRestoreItems(t *testing.T) {
|
||||
),
|
||||
},
|
||||
expectedRestoreItems: map[itemKey]restoredItemStatus{
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true},
|
||||
{resource: "v1/Pod", namespace: "ns-1", name: "pod-1"}: {action: "created", itemExists: true},
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true, createdName: "ns-1"},
|
||||
{resource: "v1/Pod", namespace: "ns-1", name: "pod-1"}: {action: "created", itemExists: true, createdName: "pod-1"},
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -1201,7 +1201,7 @@ func TestRestoreItems(t *testing.T) {
|
||||
test.ServiceAccounts(builder.ForServiceAccount("ns-1", "sa-1").Result()),
|
||||
},
|
||||
expectedRestoreItems: map[itemKey]restoredItemStatus{
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true},
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true, createdName: "ns-1"},
|
||||
{resource: "v1/ServiceAccount", namespace: "ns-1", name: "sa-1"}: {action: "skipped", itemExists: true},
|
||||
},
|
||||
},
|
||||
@@ -1220,7 +1220,7 @@ func TestRestoreItems(t *testing.T) {
|
||||
test.Secrets(builder.ForSecret("ns-1", "sa-1").ObjectMeta(builder.WithLabels("velero.io/backup-name", "backup-1", "velero.io/restore-name", "restore-1")).Data(map[string][]byte{"key-1": []byte("value-1")}).Result()),
|
||||
},
|
||||
expectedRestoreItems: map[itemKey]restoredItemStatus{
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true},
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true, createdName: "ns-1"},
|
||||
{resource: "v1/Secret", namespace: "ns-1", name: "sa-1"}: {action: "updated", itemExists: true},
|
||||
},
|
||||
},
|
||||
@@ -1239,7 +1239,7 @@ func TestRestoreItems(t *testing.T) {
|
||||
test.Secrets(builder.ForSecret("ns-1", "sa-1").ObjectMeta(builder.WithLabels("velero.io/backup-name", "backup-1", "velero.io/restore-name", "restore-1")).Data(map[string][]byte{"key-1": []byte("value-1")}).Result()),
|
||||
},
|
||||
expectedRestoreItems: map[itemKey]restoredItemStatus{
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true},
|
||||
{resource: "v1/Namespace", namespace: "", name: "ns-1"}: {action: "created", itemExists: true, createdName: "ns-1"},
|
||||
{resource: "v1/Secret", namespace: "ns-1", name: "sa-1"}: {action: "updated", itemExists: true},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user