diff --git a/changelogs/unreleased/1587-prydonius b/changelogs/unreleased/1587-prydonius new file mode 100644 index 000000000..db3cc1ced --- /dev/null +++ b/changelogs/unreleased/1587-prydonius @@ -0,0 +1 @@ +ensures backup item action modifications to an item's namespace/name are saved in the file path in the tarball diff --git a/pkg/backup/backup_new_test.go b/pkg/backup/backup_new_test.go index 639622e15..7a8b93338 100644 --- a/pkg/backup/backup_new_test.go +++ b/pkg/backup/backup_new_test.go @@ -1006,8 +1006,7 @@ func TestBackupActionModifications(t *testing.T) { }, }, { - // TODO this seems like a bug - name: "modifications to name and namespace in an action are persisted in JSON but not in filename", + name: "modifications to name and namespace in an action are persisted in JSON and in filename", backup: defaultBackup(). Backup(), apiResources: []*apiResource{ @@ -1022,7 +1021,7 @@ func TestBackupActionModifications(t *testing.T) { }), }, want: map[string]unstructuredObject{ - "resources/pods/namespaces/ns-1/pod-1.json": toUnstructuredOrFail(t, newPod("ns-1-updated", "pod-1-updated")), + "resources/pods/namespaces/ns-1-updated/pod-1-updated.json": toUnstructuredOrFail(t, newPod("ns-1-updated", "pod-1-updated")), }, }, } diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index 6b4b83698..189f562c0 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -206,6 +206,9 @@ func (ib *defaultItemBackupper) backupItem(logger logrus.FieldLogger, obj runtim if metadata, err = meta.Accessor(obj); err != nil { return errors.WithStack(err) } + // update name and namespace in case they were modified in an action + name = metadata.GetName() + namespace = metadata.GetNamespace() if groupResource == kuberesource.PersistentVolumes { if err := ib.takePVSnapshot(obj, log); err != nil {