mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-07-31 20:36:07 +00:00
Merge pull request #9896 from shubham-pampattiwar/fix/skip-vgsc-cleanup-no-vgs
Main CI / get-go-version (push) Successful in 1m12s
Close stale issues and PRs / stale (push) Successful in 15s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 2m16s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m44s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m24s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m21s
Main CI / Build (push) Has been cancelled
Main CI / get-go-version (push) Successful in 1m12s
Close stale issues and PRs / stale (push) Successful in 15s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 2m16s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-aws, main) (push) Failing after 1m44s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-gcp, main) (push) Failing after 1m24s
Trivy Nightly Scan / Trivy nightly scan (velero-plugin-for-microsoft-azure, main) (push) Failing after 1m21s
Main CI / Build (push) Has been cancelled
Skip VGS cleanup when backup did not use VolumeGroupSnapshots
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Skip VGS cleanup when backup did not use VolumeGroupSnapshots
|
||||
@@ -301,8 +301,10 @@ func (ctx *finalizerContext) execute() (results.Result, results.Result) {
|
||||
pdpErrs := ctx.patchDynamicPVWithVolumeInfo()
|
||||
errs.Merge(&pdpErrs)
|
||||
|
||||
vgscWarnings := ctx.cleanupStubVGSC()
|
||||
warnings.Merge(&vgscWarnings)
|
||||
if ctx.hasVolumeGroupSnapshotHandles() {
|
||||
vgscWarnings := ctx.cleanupStubVGSC()
|
||||
warnings.Merge(&vgscWarnings)
|
||||
}
|
||||
|
||||
rehErrs := ctx.WaitRestoreExecHook()
|
||||
errs.Merge(&rehErrs)
|
||||
@@ -449,6 +451,15 @@ func (ctx *finalizerContext) patchDynamicPVWithVolumeInfo() (errs results.Result
|
||||
return errs
|
||||
}
|
||||
|
||||
func (ctx *finalizerContext) hasVolumeGroupSnapshotHandles() bool {
|
||||
for _, vi := range ctx.volumeInfo {
|
||||
if vi.CSISnapshotInfo != nil && vi.CSISnapshotInfo.VolumeGroupSnapshotHandle != "" {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// cleanupStubVGSC deletes stub VolumeGroupSnapshotContent objects that were
|
||||
// created during restore to satisfy CSI controller validation. These stubs are
|
||||
// labeled with velero.io/restore-name for identification.
|
||||
|
||||
@@ -743,6 +743,83 @@ func TestRestoreOperationList(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestHasVolumeGroupSnapshotHandles(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
volumeInfo []*volume.BackupVolumeInfo
|
||||
expected bool
|
||||
}{
|
||||
{
|
||||
name: "nil volumeInfo",
|
||||
volumeInfo: nil,
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "empty volumeInfo",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "no CSISnapshotInfo",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{
|
||||
{PVCName: "pvc-1", BackupMethod: volume.NativeSnapshot},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "CSISnapshotInfo with empty VolumeGroupSnapshotHandle",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{
|
||||
{
|
||||
PVCName: "pvc-1",
|
||||
BackupMethod: volume.CSISnapshot,
|
||||
CSISnapshotInfo: &volume.CSISnapshotInfo{
|
||||
SnapshotHandle: "snap-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: false,
|
||||
},
|
||||
{
|
||||
name: "one volume with VolumeGroupSnapshotHandle",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{
|
||||
{
|
||||
PVCName: "pvc-1",
|
||||
BackupMethod: volume.CSISnapshot,
|
||||
CSISnapshotInfo: &volume.CSISnapshotInfo{
|
||||
SnapshotHandle: "snap-1",
|
||||
VolumeGroupSnapshotHandle: "vgs-handle-1",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
{
|
||||
name: "mixed volumes only one with VolumeGroupSnapshotHandle",
|
||||
volumeInfo: []*volume.BackupVolumeInfo{
|
||||
{PVCName: "pvc-1", BackupMethod: volume.NativeSnapshot},
|
||||
{
|
||||
PVCName: "pvc-2",
|
||||
BackupMethod: volume.CSISnapshot,
|
||||
CSISnapshotInfo: &volume.CSISnapshotInfo{
|
||||
SnapshotHandle: "snap-2",
|
||||
VolumeGroupSnapshotHandle: "vgs-handle-2",
|
||||
},
|
||||
},
|
||||
},
|
||||
expected: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
ctx := &finalizerContext{
|
||||
volumeInfo: tc.volumeInfo,
|
||||
}
|
||||
assert.Equal(t, tc.expected, ctx.hasVolumeGroupSnapshotHandles())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestCleanupStubVGSC(t *testing.T) {
|
||||
snapshotHandle1 := "snap-handle-1"
|
||||
snapshotHandle2 := "snap-handle-2"
|
||||
|
||||
Reference in New Issue
Block a user