mirror of https://github.com/k3s-io/k3s
Merge pull request #59701 from mlmhl/kubectl_describe_pvc_condition
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Add description of pvc condition for kubectl describe command **What this PR does / why we need it**: As the title says, add description of `PersistentVolumeClaim.Status.Conditions` for `kubectl describe pvc` command, the output will look like this: ``` Conditions: Type Status LastProbeTime LastTransitionTime Reason Message ---- ------ ----------------- ------------------ ------ ------- Resizing True Mon, 01 Jan 0001 00:00:00 +0000 Sat, 10 Feb 2018 19:20:56 +0800 ``` **Release note**: ```release-note NONE ``` /sig storage /kind enhancementpull/8/head
commit
707b7fd179
|
@ -1307,6 +1307,20 @@ func describePersistentVolumeClaim(pvc *api.PersistentVolumeClaim, events *api.E
|
|||
if pvc.Spec.VolumeMode != nil {
|
||||
w.Write(LEVEL_0, "VolumeMode:\t%v\n", *pvc.Spec.VolumeMode)
|
||||
}
|
||||
if len(pvc.Status.Conditions) > 0 {
|
||||
w.Write(LEVEL_0, "Conditions:\n")
|
||||
w.Write(LEVEL_1, "Type\tStatus\tLastProbeTime\tLastTransitionTime\tReason\tMessage\n")
|
||||
w.Write(LEVEL_1, "----\t------\t-----------------\t------------------\t------\t-------\n")
|
||||
for _, c := range pvc.Status.Conditions {
|
||||
w.Write(LEVEL_1, "%v \t%v \t%s \t%s \t%v \t%v\n",
|
||||
c.Type,
|
||||
c.Status,
|
||||
c.LastProbeTime.Time.Format(time.RFC1123Z),
|
||||
c.LastTransitionTime.Time.Format(time.RFC1123Z),
|
||||
c.Reason,
|
||||
c.Message)
|
||||
}
|
||||
}
|
||||
if events != nil {
|
||||
DescribeEvents(events, w)
|
||||
}
|
||||
|
|
|
@ -1120,6 +1120,7 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
|||
block := api.PersistentVolumeBlock
|
||||
file := api.PersistentVolumeFilesystem
|
||||
goldClassName := "gold"
|
||||
now := time.Now()
|
||||
testCases := []struct {
|
||||
name string
|
||||
pvc *api.PersistentVolumeClaim
|
||||
|
@ -1170,6 +1171,103 @@ func TestPersistentVolumeClaimDescriber(t *testing.T) {
|
|||
},
|
||||
expectedElements: []string{"VolumeMode", "Block"},
|
||||
},
|
||||
// Tests for Status.Condition.
|
||||
{
|
||||
name: "condition-type",
|
||||
pvc: &api.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume4",
|
||||
StorageClassName: &goldClassName,
|
||||
},
|
||||
Status: api.PersistentVolumeClaimStatus{
|
||||
Conditions: []api.PersistentVolumeClaimCondition{
|
||||
{Type: api.PersistentVolumeClaimResizing},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedElements: []string{"Conditions", "Type", "Resizing"},
|
||||
},
|
||||
{
|
||||
name: "condition-status",
|
||||
pvc: &api.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume5",
|
||||
StorageClassName: &goldClassName,
|
||||
},
|
||||
Status: api.PersistentVolumeClaimStatus{
|
||||
Conditions: []api.PersistentVolumeClaimCondition{
|
||||
{Status: api.ConditionTrue},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedElements: []string{"Conditions", "Status", "True"},
|
||||
},
|
||||
{
|
||||
name: "condition-last-probe-time",
|
||||
pvc: &api.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume6",
|
||||
StorageClassName: &goldClassName,
|
||||
},
|
||||
Status: api.PersistentVolumeClaimStatus{
|
||||
Conditions: []api.PersistentVolumeClaimCondition{
|
||||
{LastProbeTime: metav1.Time{Time: now}},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedElements: []string{"Conditions", "LastProbeTime", now.Format(time.RFC1123Z)},
|
||||
},
|
||||
{
|
||||
name: "condition-last-transition-time",
|
||||
pvc: &api.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume7",
|
||||
StorageClassName: &goldClassName,
|
||||
},
|
||||
Status: api.PersistentVolumeClaimStatus{
|
||||
Conditions: []api.PersistentVolumeClaimCondition{
|
||||
{LastTransitionTime: metav1.Time{Time: now}},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedElements: []string{"Conditions", "LastTransitionTime", now.Format(time.RFC1123Z)},
|
||||
},
|
||||
{
|
||||
name: "condition-reason",
|
||||
pvc: &api.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume8",
|
||||
StorageClassName: &goldClassName,
|
||||
},
|
||||
Status: api.PersistentVolumeClaimStatus{
|
||||
Conditions: []api.PersistentVolumeClaimCondition{
|
||||
{Reason: "OfflineResize"},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedElements: []string{"Conditions", "Reason", "OfflineResize"},
|
||||
},
|
||||
{
|
||||
name: "condition-message",
|
||||
pvc: &api.PersistentVolumeClaim{
|
||||
ObjectMeta: metav1.ObjectMeta{Namespace: "foo", Name: "bar"},
|
||||
Spec: api.PersistentVolumeClaimSpec{
|
||||
VolumeName: "volume9",
|
||||
StorageClassName: &goldClassName,
|
||||
},
|
||||
Status: api.PersistentVolumeClaimStatus{
|
||||
Conditions: []api.PersistentVolumeClaimCondition{
|
||||
{Message: "User request resize"},
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedElements: []string{"Conditions", "Message", "User request resize"},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
|
Loading…
Reference in New Issue