Backport of volume-status : show namespace the volume belongs to into release/1.6.x (#17997)

This pull request was automerged via backport-assistant
This commit is contained in:
hc-github-team-nomad-core 2023-07-19 15:37:18 -05:00 committed by GitHub
parent e5fb6fe687
commit 3011314f23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 13 deletions

3
.changelog/17911.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
cli: Display volume namespace on `nomad volume status` and `nomad node status` output
```

View File

@ -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,

View File

@ -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)
}

View File

@ -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,
@ -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),

View File

@ -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

View File

@ -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