Skip to content

Commit

Permalink
filter volumes by type in 'nomad node status' output
Browse files Browse the repository at this point in the history
Volume requests can be either CSI or host volumes, so when displaying the CSI
volume info for `nomad node status -verbose` we need to filter out the host
volumes.
  • Loading branch information
tgross committed Sep 16, 2020
1 parent 679fee9 commit f0b140f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/nomad/api"
"github.com/hashicorp/nomad/api/contexts"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
"github.com/posener/complete"
)

Expand Down Expand Up @@ -550,8 +551,10 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap
}

for _, v := range tg.Volumes {
names = append(names, v.Name)
requests[v.Source] = v
if v.Type == structs.VolumeTypeCSI {
names = append(names, v.Name)
requests[v.Source] = v
}
}
}
if len(names) == 0 {
Expand All @@ -577,16 +580,18 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap
output := make([]string, 0, len(names)+1)
output = append(output, "ID|Name|Plugin ID|Schedulable|Provider|Access Mode")
for _, name := range names {
v := volumes[name]
output = append(output, fmt.Sprintf(
"%s|%s|%s|%t|%s|%s",
v.ID,
name,
v.PluginID,
v.Schedulable,
v.Provider,
v.AccessMode,
))
v, ok := volumes[name]
if ok {
output = append(output, fmt.Sprintf(
"%s|%s|%s|%t|%s|%s",
v.ID,
name,
v.PluginID,
v.Schedulable,
v.Provider,
v.AccessMode,
))
}
}

c.Ui.Output(formatList(output))
Expand Down

0 comments on commit f0b140f

Please sign in to comment.