Merge pull request #6303 from Lyndon-Li/data-mover-generic-data-path-issue-fix

Fix PVR issue for generic data path
pull/6307/head
lyndon 2023-05-23 18:09:07 +08:00 committed by GitHub
commit 53623a75ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 3 deletions

View File

@ -0,0 +1 @@
Fix a PVR issue for generic data path -- the namespace remap was not honored, and enhance the code for better error handling

View File

@ -142,7 +142,7 @@ func (c *PodVolumeRestoreReconciler) Reconcile(ctx context.Context, req ctrl.Req
log.WithField("path", volumePath.ByPath).Debugf("Found host path")
if err := fsRestore.Init(ctx, pvr.Spec.BackupStorageLocation, pvr.Spec.Pod.Namespace, pvr.Spec.UploaderType,
if err := fsRestore.Init(ctx, pvr.Spec.BackupStorageLocation, pvr.Spec.SourceNamespace, pvr.Spec.UploaderType,
podvolume.GetPvrRepositoryType(pvr), pvr.Spec.RepoIdentifier, c.repositoryEnsurer, c.credentialGetter); err != nil {
return c.errorOut(ctx, pvr, err, "error to initialize data path", log)
}
@ -323,7 +323,7 @@ func (c *PodVolumeRestoreReconciler) OnDataPathFailed(ctx context.Context, names
log := c.logger.WithField("pvr", pvrName)
log.WithError(err).Info("Async fs restore data path failed")
log.WithError(err).Error("Async fs restore data path failed")
var pvr velerov1api.PodVolumeRestore
if getErr := c.Client.Get(ctx, types.NamespacedName{Name: pvrName, Namespace: namespace}, &pvr); getErr != nil {
@ -338,7 +338,7 @@ func (c *PodVolumeRestoreReconciler) OnDataPathCancelled(ctx context.Context, na
log := c.logger.WithField("pvr", pvrName)
log.Info("Async fs restore data path canceled")
log.Warn("Async fs restore data path canceled")
var pvr velerov1api.PodVolumeRestore
if getErr := c.Client.Get(ctx, types.NamespacedName{Name: pvrName, Namespace: namespace}, &pvr); getErr != nil {

View File

@ -256,6 +256,15 @@ func findPreviousSnapshotManifest(ctx context.Context, rep repo.Repository, sour
continue
}
uploaderName, found := p.Tags[uploader.SnapshotUploaderTag]
if !found {
continue
}
if uploaderName != snapshotTags[uploader.SnapshotUploaderTag] {
continue
}
if noLaterThan != nil && p.StartTime.After(*noLaterThan) {
continue
}
@ -278,6 +287,13 @@ func Restore(ctx context.Context, rep repo.RepositoryWriter, progress *Progress,
kopiaCtx := logging.SetupKopiaLog(ctx, log)
snapshot, err := snapshot.LoadSnapshot(kopiaCtx, rep, manifest.ID(snapshotID))
if err != nil {
return 0, 0, errors.Wrapf(err, "Unable to load snapshot %v", snapshotID)
}
log.Infof("Restore from snapshot %s, description %s, created time %v, tags %v", snapshotID, snapshot.Description, snapshot.EndTime.ToTime(), snapshot.Tags)
rootEntry, err := snapshotfs.FilesystemEntryFromIDWithPath(kopiaCtx, rep, snapshotID, false)
if err != nil {
return 0, 0, errors.Wrapf(err, "Unable to get filesystem entry for snapshot %v", snapshotID)

View File

@ -144,6 +144,7 @@ func (kp *kopiaProvider) RunBackup(
tags = make(map[string]string)
}
tags[uploader.SnapshotRequestorTag] = kp.requestorType
tags[uploader.SnapshotUploaderTag] = uploader.KopiaType
snapshotInfo, isSnapshotEmpty, err := BackupFunc(ctx, kpUploader, repoWriter, path, forceFull, parentSnapshot, tags, log)
if err != nil {

View File

@ -25,6 +25,7 @@ const (
ResticType = "restic"
KopiaType = "kopia"
SnapshotRequestorTag = "snapshot-requestor"
SnapshotUploaderTag = "snapshot-uploader"
)
// ValidateUploaderType validates if the input param is a valid uploader type.