Skip to content

Commit

Permalink
Clarify the conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
RidRisR committed Sep 27, 2024
1 parent 0a8b093 commit ff7210e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion pkg/apis/pingcap/v1alpha1/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ func IsLogBackupStopped(backup *Backup) bool {

// IsBackupClean returns true if a Backup has been successfully cleaned up
func IsBackupClean(backup *Backup) bool {
if backup.Spec.Mode == BackupModeLog && !IsLogBackupAlreadyStop(backup){
// TODO: now we don't handle fault state, maybe we should consider it in the future
if backup.Spec.Mode == BackupModeLog && IsLogBackupOnTrack(backup) {
return false
}
if NeedRetainData(backup) {
Expand Down Expand Up @@ -402,3 +403,11 @@ func IsLogBackupAlreadyTruncate(backup *Backup) bool {
func IsLogBackupAlreadyStop(backup *Backup) bool {
return backup.Spec.Mode == BackupModeLog && backup.Status.Phase == BackupStopped
}

// IsLogBackupOnTrack return whether log backup is on track.
func IsLogBackupOnTrack(backup *Backup) bool {
return backup.Spec.Mode == BackupModeLog &&
backup.Status.Phase == BackupScheduled ||
backup.Status.Phase == BackupPrepare ||
backup.Status.Phase == BackupRunning
}
2 changes: 1 addition & 1 deletion pkg/backup/backup/backup_cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (bc *backupCleaner) CleanLogBackup(backup *v1alpha1.Backup) error {

return bc.statusUpdater.Update(backup, &v1alpha1.BackupCondition{
Command: v1alpha1.LogStopCommand,
Type: v1alpha1.BackupComplete,
Type: v1alpha1.BackupScheduled,
Status: corev1.ConditionTrue,
}, nil)
}
Expand Down

0 comments on commit ff7210e

Please sign in to comment.