Skip to content

Commit c041411

Browse files
committed
PWX-33934: remove tight loop around volumeBackup status check
- Removed the frequent BackupId check while a volume backup is in progress It is being called in a tight for-loop, now it is called every reconciler sync interval. Signed-off-by: Lalatendu Das <[email protected]>
1 parent baefe05 commit c041411

File tree

1 file changed

+25
-39
lines changed

1 file changed

+25
-39
lines changed

pkg/applicationmanager/controllers/applicationbackup.go

Lines changed: 25 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ func (a *ApplicationBackupController) backupVolumes(backup *stork_api.Applicatio
660660
namespacedName.Namespace = backup.Namespace
661661
namespacedName.Name = backup.Name
662662
if len(backup.Status.Volumes) != pvcCount {
663-
664663
for driverName, pvcs := range pvcMappings {
665664
var driver volume.Driver
666665
driver, err = volume.Get(driverName)
@@ -726,44 +725,31 @@ func (a *ApplicationBackupController) backupVolumes(backup *stork_api.Applicatio
726725
if err != nil {
727726
return err
728727
}
729-
// In case Portworx if the snapshot ID is populated for every volume then the snapshot
730-
// process is considered to be completed successfully.
731-
// This ensures we don't execute the post-exec before all volume's snapshot is completed
732-
if driverName == volume.PortworxDriverName {
733-
startTime := time.Now()
734-
for {
735-
// In case below logic genuinely takes long time for many volumes
736-
// the CR timestamp need to be updated. This prevents backup timeout error.
737-
elapsedTime := time.Since(startTime)
738-
if elapsedTime > utils.TimeoutUpdateBackupCrTimestamp {
739-
backup, err = a.updateBackupCRInVolumeStage(
740-
namespacedName,
741-
stork_api.ApplicationBackupStatusInProgress,
742-
backup.Status.Stage,
743-
"Volume backups are in progress",
744-
volumeInfos,
745-
)
746-
if err != nil {
747-
return err
748-
}
749-
startTime = time.Now()
750-
}
751-
// Get fresh stock of the status for all volumes.
752-
snapshotNotCompleted := false
753-
volumeInfos, err = driver.GetBackupStatus(backup)
754-
if err != nil {
755-
log.ApplicationBackupLog(backup).Errorf("error getting backup status for driver %v: %v", driverName, err)
756-
return fmt.Errorf("error getting backup status for driver %v: %v", driverName, err)
757-
}
758-
for _, volInfo := range volumeInfos {
759-
if volInfo.BackupID == "" {
760-
log.ApplicationBackupLog(backup).Tracef("Snapshot of volume %v is not done yet, need to loop till snapshot is done...", volInfo.PersistentVolumeClaim)
761-
snapshotNotCompleted = true
762-
}
763-
}
764-
if !snapshotNotCompleted {
765-
break
766-
}
728+
}
729+
}
730+
731+
// In case Portworx if the snapshot ID is populated for every volume then the snapshot
732+
// process is considered to be completed successfully.
733+
// This ensures we don't execute the post-exec before all volume's snapshot is completed
734+
for driverName := range pvcMappings {
735+
var driver volume.Driver
736+
driver, err = volume.Get(driverName)
737+
if err != nil {
738+
return err
739+
}
740+
if driverName == volume.PortworxDriverName {
741+
volumeInfos, err := driver.GetBackupStatus(backup)
742+
if err != nil {
743+
return fmt.Errorf("error getting backup status: %v", err)
744+
}
745+
for _, volInfo := range volumeInfos {
746+
if volInfo.BackupID == "" {
747+
log.ApplicationBackupLog(backup).Infof("Snapshot of volume [%v] hasn't completed yet, retry checking status", volInfo.PersistentVolumeClaim)
748+
// Some portworx volume snapshot is not completed yet
749+
// hence we will retry checking the status in the next reconciler iteration
750+
// *stork_api.ApplicationBackupVolumeInfo.Status is not being checked here
751+
// since backpID confirms if the snapshot is done or not already
752+
return nil
767753
}
768754
}
769755
}

0 commit comments

Comments
 (0)