mirror of https://github.com/k3s-io/k3s
Bugfix: kubectl shows last<invalid> if pv, pod, pvc is terminating
fix describe utpull/564/head
parent
824883d08a
commit
bdfd420c6d
|
@ -674,7 +674,7 @@ func describePod(pod *corev1.Pod, events *corev1.EventList) (string, error) {
|
|||
printLabelsMultiline(w, "Labels", pod.Labels)
|
||||
printAnnotationsMultiline(w, "Annotations", pod.Annotations)
|
||||
if pod.DeletionTimestamp != nil {
|
||||
w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampUntil(*pod.DeletionTimestamp))
|
||||
w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampSince(*pod.DeletionTimestamp))
|
||||
w.Write(LEVEL_0, "Termination Grace Period:\t%ds\n", *pod.DeletionGracePeriodSeconds)
|
||||
} else {
|
||||
w.Write(LEVEL_0, "Status:\t%s\n", string(pod.Status.Phase))
|
||||
|
@ -1329,7 +1329,7 @@ func describePersistentVolume(pv *corev1.PersistentVolume, events *corev1.EventL
|
|||
w.Write(LEVEL_0, "Finalizers:\t%v\n", pv.ObjectMeta.Finalizers)
|
||||
w.Write(LEVEL_0, "StorageClass:\t%s\n", storageutil.GetPersistentVolumeClass(pv))
|
||||
if pv.ObjectMeta.DeletionTimestamp != nil {
|
||||
w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampUntil(*pv.ObjectMeta.DeletionTimestamp))
|
||||
w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampSince(*pv.ObjectMeta.DeletionTimestamp))
|
||||
} else {
|
||||
w.Write(LEVEL_0, "Status:\t%v\n", pv.Status.Phase)
|
||||
}
|
||||
|
@ -1470,7 +1470,7 @@ func describePersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim, events *co
|
|||
w.Write(LEVEL_0, "Namespace:\t%s\n", pvc.Namespace)
|
||||
w.Write(LEVEL_0, "StorageClass:\t%s\n", storageutil.GetPersistentVolumeClaimClass(pvc))
|
||||
if pvc.ObjectMeta.DeletionTimestamp != nil {
|
||||
w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampUntil(*pvc.ObjectMeta.DeletionTimestamp))
|
||||
w.Write(LEVEL_0, "Status:\tTerminating (lasts %s)\n", translateTimestampSince(*pvc.ObjectMeta.DeletionTimestamp))
|
||||
} else {
|
||||
w.Write(LEVEL_0, "Status:\t%v\n", pvc.Status.Phase)
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ type describeClient struct {
|
|||
}
|
||||
|
||||
func TestDescribePod(t *testing.T) {
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(10, 0, 0)}
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(-10, 0, 0)}
|
||||
gracePeriod := int64(1234)
|
||||
condition1 := corev1.PodConditionType("condition1")
|
||||
condition2 := corev1.PodConditionType("condition2")
|
||||
|
@ -937,7 +937,7 @@ func TestGetPodsTotalRequests(t *testing.T) {
|
|||
func TestPersistentVolumeDescriber(t *testing.T) {
|
||||
block := corev1.PersistentVolumeBlock
|
||||
file := corev1.PersistentVolumeFilesystem
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(10, 0, 0)}
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(-10, 0, 0)}
|
||||
testCases := []struct {
|
||||
name string
|
||||
plugin string
|
||||
|
@ -1305,7 +1305,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
|||
file := corev1.PersistentVolumeFilesystem
|
||||
goldClassName := "gold"
|
||||
now := time.Now()
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(10, 0, 0)}
|
||||
deletionTimestamp := metav1.Time{Time: time.Now().UTC().AddDate(-10, 0, 0)}
|
||||
testCases := []struct {
|
||||
name string
|
||||
pvc *corev1.PersistentVolumeClaim
|
||||
|
|
Loading…
Reference in New Issue