Merge pull request #8946 from blackpiglet/remove_csi_metadata
Remove CSI VS and VSC metadata from backup.pull/8970/head^2
commit
468a969c10
|
@ -0,0 +1 @@
|
||||||
|
Remove CSI VS and VSC metadata from backup.
|
|
@ -833,15 +833,6 @@ func persistBackup(backup *pkgbackup.Request,
|
||||||
persistErrs = append(persistErrs, errs...)
|
persistErrs = append(persistErrs, errs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
csiSnapshotJSON, errs := encode.ToJSONGzip(csiVolumeSnapshots, "csi volume snapshots list")
|
|
||||||
if errs != nil {
|
|
||||||
persistErrs = append(persistErrs, errs...)
|
|
||||||
}
|
|
||||||
|
|
||||||
csiSnapshotContentsJSON, errs := encode.ToJSONGzip(csiVolumeSnapshotContents, "csi volume snapshot contents list")
|
|
||||||
if errs != nil {
|
|
||||||
persistErrs = append(persistErrs, errs...)
|
|
||||||
}
|
|
||||||
csiSnapshotClassesJSON, errs := encode.ToJSONGzip(csiVolumeSnapshotClasses, "csi volume snapshot classes list")
|
csiSnapshotClassesJSON, errs := encode.ToJSONGzip(csiVolumeSnapshotClasses, "csi volume snapshot classes list")
|
||||||
if errs != nil {
|
if errs != nil {
|
||||||
persistErrs = append(persistErrs, errs...)
|
persistErrs = append(persistErrs, errs...)
|
||||||
|
@ -877,8 +868,6 @@ func persistBackup(backup *pkgbackup.Request,
|
||||||
nativeVolumeSnapshots = nil
|
nativeVolumeSnapshots = nil
|
||||||
backupItemOperations = nil
|
backupItemOperations = nil
|
||||||
backupResourceList = nil
|
backupResourceList = nil
|
||||||
csiSnapshotJSON = nil
|
|
||||||
csiSnapshotContentsJSON = nil
|
|
||||||
csiSnapshotClassesJSON = nil
|
csiSnapshotClassesJSON = nil
|
||||||
backupResult = nil
|
backupResult = nil
|
||||||
volumeInfoJSON = nil
|
volumeInfoJSON = nil
|
||||||
|
@ -894,8 +883,6 @@ func persistBackup(backup *pkgbackup.Request,
|
||||||
VolumeSnapshots: nativeVolumeSnapshots,
|
VolumeSnapshots: nativeVolumeSnapshots,
|
||||||
BackupItemOperations: backupItemOperations,
|
BackupItemOperations: backupItemOperations,
|
||||||
BackupResourceList: backupResourceList,
|
BackupResourceList: backupResourceList,
|
||||||
CSIVolumeSnapshots: csiSnapshotJSON,
|
|
||||||
CSIVolumeSnapshotContents: csiSnapshotContentsJSON,
|
|
||||||
CSIVolumeSnapshotClasses: csiSnapshotClassesJSON,
|
CSIVolumeSnapshotClasses: csiSnapshotClassesJSON,
|
||||||
BackupVolumeInfo: volumeInfoJSON,
|
BackupVolumeInfo: volumeInfoJSON,
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,6 @@ type BackupInfo struct {
|
||||||
VolumeSnapshots,
|
VolumeSnapshots,
|
||||||
BackupItemOperations,
|
BackupItemOperations,
|
||||||
BackupResourceList,
|
BackupResourceList,
|
||||||
CSIVolumeSnapshots,
|
|
||||||
CSIVolumeSnapshotContents,
|
|
||||||
CSIVolumeSnapshotClasses,
|
CSIVolumeSnapshotClasses,
|
||||||
BackupVolumeInfo io.Reader
|
BackupVolumeInfo io.Reader
|
||||||
}
|
}
|
||||||
|
@ -72,7 +70,6 @@ type BackupStore interface {
|
||||||
GetPodVolumeBackups(name string) ([]*velerov1api.PodVolumeBackup, error)
|
GetPodVolumeBackups(name string) ([]*velerov1api.PodVolumeBackup, error)
|
||||||
GetBackupContents(name string) (io.ReadCloser, error)
|
GetBackupContents(name string) (io.ReadCloser, error)
|
||||||
GetCSIVolumeSnapshots(name string) ([]*snapshotv1api.VolumeSnapshot, error)
|
GetCSIVolumeSnapshots(name string) ([]*snapshotv1api.VolumeSnapshot, error)
|
||||||
GetCSIVolumeSnapshotContents(name string) ([]*snapshotv1api.VolumeSnapshotContent, error)
|
|
||||||
GetCSIVolumeSnapshotClasses(name string) ([]*snapshotv1api.VolumeSnapshotClass, error)
|
GetCSIVolumeSnapshotClasses(name string) ([]*snapshotv1api.VolumeSnapshotClass, error)
|
||||||
PutBackupVolumeInfos(name string, volumeInfo io.Reader) error
|
PutBackupVolumeInfos(name string, volumeInfo io.Reader) error
|
||||||
GetBackupVolumeInfos(name string) ([]*volume.BackupVolumeInfo, error)
|
GetBackupVolumeInfos(name string) ([]*volume.BackupVolumeInfo, error)
|
||||||
|
@ -273,8 +270,6 @@ func (s *objectBackupStore) PutBackup(info BackupInfo) error {
|
||||||
s.layout.getBackupVolumeSnapshotsKey(info.Name): info.VolumeSnapshots,
|
s.layout.getBackupVolumeSnapshotsKey(info.Name): info.VolumeSnapshots,
|
||||||
s.layout.getBackupItemOperationsKey(info.Name): info.BackupItemOperations,
|
s.layout.getBackupItemOperationsKey(info.Name): info.BackupItemOperations,
|
||||||
s.layout.getBackupResourceListKey(info.Name): info.BackupResourceList,
|
s.layout.getBackupResourceListKey(info.Name): info.BackupResourceList,
|
||||||
s.layout.getCSIVolumeSnapshotKey(info.Name): info.CSIVolumeSnapshots,
|
|
||||||
s.layout.getCSIVolumeSnapshotContentsKey(info.Name): info.CSIVolumeSnapshotContents,
|
|
||||||
s.layout.getCSIVolumeSnapshotClassesKey(info.Name): info.CSIVolumeSnapshotClasses,
|
s.layout.getCSIVolumeSnapshotClassesKey(info.Name): info.CSIVolumeSnapshotClasses,
|
||||||
s.layout.getBackupResultsKey(info.Name): info.BackupResults,
|
s.layout.getBackupResultsKey(info.Name): info.BackupResults,
|
||||||
s.layout.getBackupVolumeInfoKey(info.Name): info.BackupVolumeInfo,
|
s.layout.getBackupVolumeInfoKey(info.Name): info.BackupVolumeInfo,
|
||||||
|
|
|
@ -863,40 +863,6 @@ func TestGetCSIVolumeSnapshots(t *testing.T) {
|
||||||
assert.EqualValues(t, snapshots, res)
|
assert.EqualValues(t, snapshots, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCSIVolumeSnapshotContents(t *testing.T) {
|
|
||||||
harness := newObjectBackupStoreTestHarness("test-bucket", "")
|
|
||||||
|
|
||||||
// file not found should not error
|
|
||||||
res, err := harness.GetCSIVolumeSnapshotContents("test-backup")
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Nil(t, res)
|
|
||||||
|
|
||||||
// file containing invalid data should error
|
|
||||||
harness.objectStore.PutObject(harness.bucket, "backups/test-backup/test-backup-csi-volumesnapshotcontents.json.gz", newStringReadSeeker("foo"))
|
|
||||||
_, err = harness.GetCSIVolumeSnapshotContents("test-backup")
|
|
||||||
assert.Error(t, err)
|
|
||||||
|
|
||||||
// file containing gzipped json data should return correctly
|
|
||||||
contents := []*snapshotv1api.VolumeSnapshotContent{
|
|
||||||
{
|
|
||||||
Spec: snapshotv1api.VolumeSnapshotContentSpec{
|
|
||||||
Driver: "driver",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
obj := new(bytes.Buffer)
|
|
||||||
gzw := gzip.NewWriter(obj)
|
|
||||||
|
|
||||||
require.NoError(t, json.NewEncoder(gzw).Encode(contents))
|
|
||||||
require.NoError(t, gzw.Close())
|
|
||||||
require.NoError(t, harness.objectStore.PutObject(harness.bucket, "backups/test-backup/test-backup-csi-volumesnapshotcontents.json.gz", obj))
|
|
||||||
|
|
||||||
res, err = harness.GetCSIVolumeSnapshotContents("test-backup")
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.EqualValues(t, contents, res)
|
|
||||||
}
|
|
||||||
|
|
||||||
type objectStoreGetter map[string]velero.ObjectStore
|
type objectStoreGetter map[string]velero.ObjectStore
|
||||||
|
|
||||||
func (osg objectStoreGetter) GetObjectStore(provider string) (velero.ObjectStore, error) {
|
func (osg objectStoreGetter) GetObjectStore(provider string) (velero.ObjectStore, error) {
|
||||||
|
|
Loading…
Reference in New Issue