Skip to content

Commit

Permalink
chore: fix get recoverable time fail (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyelei authored Jun 20, 2024
1 parent 34fcbe6 commit ffa511a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/cmd/cluster/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,13 @@ func (o *describeOptions) getBackupRecoverableTime() (string, string, error) {
if err != nil {
return "", "", err
}
isTimeInRange := func(t metav1.Time, start *metav1.Time, end *metav1.Time) bool {
return !t.Before(start) && !t.After(end.Time)
}
sortBackup(fullBackups, false)
for _, backup := range fullBackups {
completeTime := backup.GetEndTime()
if completeTime != nil && !completeTime.Before(continuousBackup.GetStartTime()) {
if completeTime != nil && isTimeInRange(*completeTime, continuousBackup.GetStartTime(), continuousBackup.GetEndTime()) {
return fmt.Sprintf("%s ~ %s", util.TimeFormatWithDuration(completeTime, time.Second),
util.TimeFormatWithDuration(continuousBackup.GetEndTime(), time.Second)), continuousBackup.Spec.BackupMethod, nil
}
Expand Down

0 comments on commit ffa511a

Please sign in to comment.