From e75dd4bf1511b5c3d3f70aff8cd523e3bfb43f5a Mon Sep 17 00:00:00 2001 From: shaojiang Date: Fri, 7 Jul 2023 17:10:34 +0800 Subject: [PATCH] fix: snapshot failed (#4173) --- controllers/dataprotection/utils.go | 2 +- internal/controller/plan/restore.go | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/controllers/dataprotection/utils.go b/controllers/dataprotection/utils.go index fb461a91ee9..5ffbb5fec91 100644 --- a/controllers/dataprotection/utils.go +++ b/controllers/dataprotection/utils.go @@ -200,7 +200,7 @@ func sendWarningEventForError(recorder record.EventRecorder, backup *dataprotect var configVolumeSnapshotError = []string{ "Failed to set default snapshot class with error", "Failed to get snapshot class with error", - "Failed to create snapshot content with error", + "Failed to create snapshot content with error cannot find CSI PersistentVolumeSource for volume", } func isVolumeSnapshotConfigError(snap *snapshotv1.VolumeSnapshot) bool { diff --git a/internal/controller/plan/restore.go b/internal/controller/plan/restore.go index 22933c0fdf5..8b3674593cc 100644 --- a/internal/controller/plan/restore.go +++ b/internal/controller/plan/restore.go @@ -607,7 +607,10 @@ func (p *RestoreManager) BuildDatafileRestoreJobByPVCS(synthesizedComponent *com volumes = append(volumes, synthesizedComponent.PodSpec.Volumes...) volumeMounts := make([]corev1.VolumeMount, 0) for _, volume := range volumes { - volumeMounts = append(volumeMounts, volumeMountMap[volume.Name]) + if vmount, ok := volumeMountMap[volume.Name]; ok { + volumeMounts = append(volumeMounts, vmount) + } + } jobName := p.GetDatafileRestoreJobName(pvcName) job, err := builder.BuildRestoreJob(p.Cluster, synthesizedComponent, jobName, backupTool.Spec.Image,