mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-01-05 13:05:17 +00:00
Add queue position to backup list/describe
Signed-off-by: Scott Seago <sseago@redhat.com>
This commit is contained in:
@@ -75,6 +75,7 @@ func DescribeBackup(
|
||||
case velerov1api.BackupPhaseFinalizing, velerov1api.BackupPhaseFinalizingPartiallyFailed:
|
||||
case velerov1api.BackupPhaseInProgress:
|
||||
case velerov1api.BackupPhaseNew:
|
||||
case velerov1api.BackupPhaseQueued, velerov1api.BackupPhaseReadyToStart:
|
||||
}
|
||||
|
||||
logsNote := ""
|
||||
@@ -83,6 +84,9 @@ func DescribeBackup(
|
||||
}
|
||||
|
||||
d.Printf("Phase:\t%s%s\n", phaseString, logsNote)
|
||||
if phase == velerov1api.BackupPhaseQueued {
|
||||
d.Printf("Queue position:\t%v\n", backup.Status.QueuePosition)
|
||||
}
|
||||
|
||||
if backup.Spec.ResourcePolicy != nil {
|
||||
d.Println()
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
@@ -40,6 +41,7 @@ var (
|
||||
{Name: "Created"},
|
||||
{Name: "Expires"},
|
||||
{Name: "Storage Location"},
|
||||
{Name: "Queue Position"},
|
||||
{Name: "Selector"},
|
||||
}
|
||||
)
|
||||
@@ -108,6 +110,7 @@ func printBackup(backup *velerov1api.Backup) []metav1.TableRow {
|
||||
backup.Status.StartTimestamp,
|
||||
humanReadableTimeFromNow(expiration),
|
||||
backup.Spec.StorageLocation,
|
||||
queuePosition(backup.Status.QueuePosition),
|
||||
metav1.FormatLabelSelector(backup.Spec.LabelSelector),
|
||||
)
|
||||
|
||||
@@ -127,3 +130,11 @@ func humanReadableTimeFromNow(when time.Time) string {
|
||||
return fmt.Sprintf("%s ago", duration.ShortHumanDuration(now.Sub(when)))
|
||||
}
|
||||
}
|
||||
|
||||
func queuePosition(pos int) string {
|
||||
if pos == 0 {
|
||||
return ""
|
||||
} else {
|
||||
return strconv.Itoa(pos)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user