Skip to content

Commit

Permalink
volume-status : show namespace the volume belongs to (#17911)
Browse files Browse the repository at this point in the history
* volume-status : show namespace the volume belongs to
  • Loading branch information
the-nando authored and jrasell committed Jul 26, 2023
1 parent 25b6311 commit 476c2aa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .changelog/17911.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli: Display volume namespace on `nomad volume status` and `nomad node status` output
```
5 changes: 3 additions & 2 deletions command/node_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,15 @@ func (c *NodeStatusCommand) outputNodeCSIVolumeInfo(client *api.Client, node *ap

// Output the volumes in name order
output := make([]string, 0, len(names)+1)
output = append(output, "ID|Name|Plugin ID|Schedulable|Provider|Access Mode")
output = append(output, "ID|Name|Namespace|Plugin ID|Schedulable|Provider|Access Mode")
for _, name := range names {
v, ok := volumes[name]
if ok {
output = append(output, fmt.Sprintf(
"%s|%s|%s|%t|%s|%s",
"%s|%s|%s|%s|%t|%s|%s",
v.ID,
name,
v.Namespace,
v.PluginID,
v.Schedulable,
v.Provider,
Expand Down
6 changes: 3 additions & 3 deletions command/volume_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ Status Options:
queried, and drops verbose information about allocations.
-verbose
Display full allocation information.
Display full volumes information.
-json
Output the allocation in its JSON format.
Output the volumes in JSON format.
-t
Format and display allocation using a Go template.
Format and display volumes using a Go template.
`
return strings.TrimSpace(helpText)
}
Expand Down
6 changes: 4 additions & 2 deletions command/volume_status_csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,12 @@ func (c *VolumeStatusCommand) csiFormatVolumes(vols []*api.CSIVolumeListStub) (s
// Format the volumes, assumes that we're already sorted by volume ID
func csiFormatSortedVolumes(vols []*api.CSIVolumeListStub) (string, error) {
rows := make([]string, len(vols)+1)
rows[0] = "ID|Name|Plugin ID|Schedulable|Access Mode"
rows[0] = "ID|Name|Namespace|Plugin ID|Schedulable|Access Mode"
for i, v := range vols {
rows[i+1] = fmt.Sprintf("%s|%s|%s|%t|%s",
rows[i+1] = fmt.Sprintf("%s|%s|%s|%s|%t|%s",
v.ID,
v.Name,
v.Namespace,
v.PluginID,
v.Schedulable,
v.AccessMode,
Expand All @@ -212,6 +213,7 @@ func (c *VolumeStatusCommand) formatBasic(vol *api.CSIVolume) (string, error) {
output := []string{
fmt.Sprintf("ID|%s", vol.ID),
fmt.Sprintf("Name|%s", vol.Name),
fmt.Sprintf("Namespace|%s", vol.Namespace),
fmt.Sprintf("External ID|%s", vol.ExternalID),
fmt.Sprintf("Plugin ID|%s", vol.PluginID),
fmt.Sprintf("Provider|%s", vol.Provider),
Expand Down
4 changes: 2 additions & 2 deletions website/content/docs/commands/node/status.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ Host Volumes
Name ReadOnly Source
CSI Volumes
ID Name Plugin ID Schedulable Access Mode Mount Options
402f2c83 vol plug true single-node-writer <none>
ID Name Namespace Plugin ID Schedulable Access Mode Mount Options
402f2c83 vol default plug true single-node-writer <none>
Drivers
Driver Detected Healthy Message Time
Expand Down
8 changes: 4 additions & 4 deletions website/content/docs/commands/volume/status.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ List of all volumes:

```shell-session
$ nomad volume [-type csi] status
ID Name Plugin ID Schedulable Access Mode
ebs_prod_db1 database ebs-prod true single-node-writer
ID Name Namespace Plugin ID Schedulable Access Mode
ebs_prod_db1 database default ebs-prod true single-node-writer
```

List of all volumes, with external provider info:

```shell-session
$ nomad volume [-type csi] status -verbose
ID Name Plugin ID Schedulable Access Mode
ebs_prod_db1 database ebs-prod true single-node-writer
ID Name Namespace Plugin ID Schedulable Access Mode
ebs_prod_db1 database default ebs-prod true single-node-writer
External ID Condition Nodes
vol-abcedf OK i-abc123f2,i-14a12df13
Expand Down

0 comments on commit 476c2aa

Please sign in to comment.