mirror of https://github.com/k3s-io/k3s
Merge pull request #48807 from jsafrane/fc-describe
Automatic merge from submit-queue (batch tested with PRs 46094, 48544, 48807, 49102, 44174) Implement kubectl describe <fibre-channel PV> kubectl did not show any details about Fibre Channel volumes, someone just forgot to implement it. Tested with: ```shell $ kubectl create -f - <<EOF apiVersion: v1 kind: PersistentVolume metadata: name: myfc spec: capacity: storage: 100Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Delete fc: targetWWNs: ['500a0982991b8dc5', '500a0982891b8dc5'] lun: 2 fsType: ext4 readOnly: true EOF $ kubectl describe pv myfc Name: myfc Labels: <none> Annotations: <none> StorageClass: Status: Available Claim: Reclaim Policy: Delete Access Modes: RWO Capacity: 100Gi Message: Source: Type: FC (a Fibre Channel disk) TargetWWNs: 500a0982991b8dc5, 500a0982891b8dc5 LUN: 2 FSType: ext4 ReadOnly: true Events: <none> ``` ```release-note NONE ``` @kubernetes/sig-cli-pr-reviewspull/6/head
commit
89a1ce2c1f
|
@ -26,6 +26,7 @@ import (
|
|||
"net/url"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"time"
|
||||
|
@ -744,6 +745,8 @@ func describeVolumes(volumes []api.Volume, w PrefixWriter, space string) {
|
|||
printCephFSVolumeSource(volume.VolumeSource.CephFS, w)
|
||||
case volume.VolumeSource.StorageOS != nil:
|
||||
printStorageOSVolumeSource(volume.VolumeSource.StorageOS, w)
|
||||
case volume.VolumeSource.FC != nil:
|
||||
printFCVolumeSource(volume.VolumeSource.FC, w)
|
||||
default:
|
||||
w.Write(LEVEL_1, "<unknown>\n")
|
||||
}
|
||||
|
@ -960,6 +963,19 @@ func printStorageOSPersistentVolumeSource(storageos *api.StorageOSPersistentVolu
|
|||
storageos.VolumeName, storageos.VolumeNamespace, storageos.FSType, storageos.ReadOnly)
|
||||
}
|
||||
|
||||
func printFCVolumeSource(fc *api.FCVolumeSource, w PrefixWriter) {
|
||||
lun := "<none>"
|
||||
if fc.Lun != nil {
|
||||
lun = strconv.Itoa(int(*fc.Lun))
|
||||
}
|
||||
w.Write(LEVEL_2, "Type:\tFC (a Fibre Channel disk)\n"+
|
||||
" TargetWWNs:\t%v\n"+
|
||||
" LUN:\t%v\n"+
|
||||
" FSType:\t%v\n"+
|
||||
" ReadOnly:\t%v\n",
|
||||
strings.Join(fc.TargetWWNs, ", "), lun, fc.FSType, fc.ReadOnly)
|
||||
}
|
||||
|
||||
type PersistentVolumeDescriber struct {
|
||||
clientset.Interface
|
||||
}
|
||||
|
@ -1035,6 +1051,8 @@ func describePersistentVolume(pv *api.PersistentVolume, events *api.EventList) (
|
|||
printCephFSVolumeSource(pv.Spec.CephFS, w)
|
||||
case pv.Spec.StorageOS != nil:
|
||||
printStorageOSPersistentVolumeSource(pv.Spec.StorageOS, w)
|
||||
case pv.Spec.FC != nil:
|
||||
printFCVolumeSource(pv.Spec.FC, w)
|
||||
}
|
||||
|
||||
if events != nil {
|
||||
|
|
|
@ -700,6 +700,14 @@ func TestPersistentVolumeDescriber(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
"fc": {
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "bar"},
|
||||
Spec: api.PersistentVolumeSpec{
|
||||
PersistentVolumeSource: api.PersistentVolumeSource{
|
||||
FC: &api.FCVolumeSource{},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for name, pv := range tests {
|
||||
|
|
Loading…
Reference in New Issue