@@ -518,7 +518,6 @@ func (c *NodeStatusCommand) outputTruncatedNodeDriverInfo(node *api.Node) string
518
518
}
519
519
520
520
func (c * NodeStatusCommand ) outputNodeVolumeInfo (node * api.Node ) {
521
- c .Ui .Output (c .Colorize ().Color ("\n [bold]Host Volumes" ))
522
521
523
522
names := make ([]string , 0 , len (node .HostVolumes ))
524
523
for name := range node .HostVolumes {
@@ -529,15 +528,17 @@ func (c *NodeStatusCommand) outputNodeVolumeInfo(node *api.Node) {
529
528
output := make ([]string , 0 , len (names )+ 1 )
530
529
output = append (output , "Name|ReadOnly|Source" )
531
530
532
- for _ , volName := range names {
533
- info := node .HostVolumes [volName ]
534
- output = append (output , fmt .Sprintf ("%s|%v|%s" , volName , info .ReadOnly , info .Path ))
531
+ if len (names ) > 0 {
532
+ c .Ui .Output (c .Colorize ().Color ("\n [bold]Host Volumes" ))
533
+ for _ , volName := range names {
534
+ info := node .HostVolumes [volName ]
535
+ output = append (output , fmt .Sprintf ("%s|%v|%s" , volName , info .ReadOnly , info .Path ))
536
+ }
537
+ c .Ui .Output (formatList (output ))
535
538
}
536
- c .Ui .Output (formatList (output ))
537
539
}
538
540
539
541
func (c * NodeStatusCommand ) outputNodeCSIVolumeInfo (client * api.Client , node * api.Node , runningAllocs []* api.Allocation ) {
540
- c .Ui .Output (c .Colorize ().Color ("\n [bold]CSI Volumes" ))
541
542
542
543
// Duplicate nodeCSIVolumeNames to sort by name but also index volume names to ids
543
544
var names []string
@@ -563,27 +564,33 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap
563
564
volumes := map [string ]* api.CSIVolumeListStub {}
564
565
vs , _ := client .Nodes ().CSIVolumes (node .ID , nil )
565
566
for _ , v := range vs {
566
- n := requests [v .ID ].Name
567
- volumes [n ] = v
567
+ n , ok := requests [v .ID ]
568
+ if ok {
569
+ volumes [n .Name ] = v
570
+ }
568
571
}
569
572
570
- // Output the volumes in name order
571
- output := make ([]string , 0 , len (names )+ 1 )
572
- output = append (output , "ID|Name|Plugin ID|Schedulable|Provider|Access Mode" )
573
- for _ , name := range names {
574
- v := volumes [name ]
575
- output = append (output , fmt .Sprintf (
576
- "%s|%s|%s|%t|%s|%s" ,
577
- v .ID ,
578
- name ,
579
- v .PluginID ,
580
- v .Schedulable ,
581
- v .Provider ,
582
- v .AccessMode ,
583
- ))
584
- }
585
-
586
- c .Ui .Output (formatList (output ))
573
+ if len (names ) > 0 {
574
+ c .Ui .Output (c .Colorize ().Color ("\n [bold]CSI Volumes" ))
575
+
576
+ // Output the volumes in name order
577
+ output := make ([]string , 0 , len (names )+ 1 )
578
+ output = append (output , "ID|Name|Plugin ID|Schedulable|Provider|Access Mode" )
579
+ for _ , name := range names {
580
+ v := volumes [name ]
581
+ output = append (output , fmt .Sprintf (
582
+ "%s|%s|%s|%t|%s|%s" ,
583
+ v .ID ,
584
+ name ,
585
+ v .PluginID ,
586
+ v .Schedulable ,
587
+ v .Provider ,
588
+ v .AccessMode ,
589
+ ))
590
+ }
591
+
592
+ c .Ui .Output (formatList (output ))
593
+ }
587
594
}
588
595
589
596
func (c * NodeStatusCommand ) outputNodeDriverInfo (node * api.Node ) {
0 commit comments