filter volumes by type in 'nomad node status' output (#8902)
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.
This commit is contained in:
parent
f5700611c0
commit
7a691d0000
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/hashicorp/nomad/api"
|
"github.com/hashicorp/nomad/api"
|
||||||
"github.com/hashicorp/nomad/api/contexts"
|
"github.com/hashicorp/nomad/api/contexts"
|
||||||
"github.com/hashicorp/nomad/helper"
|
"github.com/hashicorp/nomad/helper"
|
||||||
|
"github.com/hashicorp/nomad/nomad/structs"
|
||||||
"github.com/posener/complete"
|
"github.com/posener/complete"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -326,9 +327,11 @@ func nodeCSIVolumeNames(n *api.Node, allocs []*api.Allocation) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range tg.Volumes {
|
for _, v := range tg.Volumes {
|
||||||
|
if v.Type == structs.VolumeTypeCSI {
|
||||||
names = append(names, v.Name)
|
names = append(names, v.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sort.Strings(names)
|
sort.Strings(names)
|
||||||
return names
|
return names
|
||||||
}
|
}
|
||||||
|
@ -550,10 +553,12 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, v := range tg.Volumes {
|
for _, v := range tg.Volumes {
|
||||||
|
if v.Type == structs.VolumeTypeCSI {
|
||||||
names = append(names, v.Name)
|
names = append(names, v.Name)
|
||||||
requests[v.Source] = v
|
requests[v.Source] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if len(names) == 0 {
|
if len(names) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -577,7 +582,8 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap
|
||||||
output := make([]string, 0, len(names)+1)
|
output := make([]string, 0, len(names)+1)
|
||||||
output = append(output, "ID|Name|Plugin ID|Schedulable|Provider|Access Mode")
|
output = append(output, "ID|Name|Plugin ID|Schedulable|Provider|Access Mode")
|
||||||
for _, name := range names {
|
for _, name := range names {
|
||||||
v := volumes[name]
|
v, ok := volumes[name]
|
||||||
|
if ok {
|
||||||
output = append(output, fmt.Sprintf(
|
output = append(output, fmt.Sprintf(
|
||||||
"%s|%s|%s|%t|%s|%s",
|
"%s|%s|%s|%t|%s|%s",
|
||||||
v.ID,
|
v.ID,
|
||||||
|
@ -588,6 +594,7 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap
|
||||||
v.AccessMode,
|
v.AccessMode,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.Ui.Output(formatList(output))
|
c.Ui.Output(formatList(output))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue