ensure backup item action modifications reflected in tarball filepath (#1587)
* ensure backup item action modifications reflected in tarball filepath This patch ensures the updated backup item's name and namespace are used when constructing the filepath for the tarball. Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com> * changelog Signed-off-by: Adnan Abdulhussein <aadnan@vmware.com>pull/1593/head
parent
5d3312b7b5
commit
2d81e29276
|
@ -0,0 +1 @@
|
|||
ensures backup item action modifications to an item's namespace/name are saved in the file path in the tarball
|
|
@ -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")),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue