Skip to content

Commit

Permalink
csi: alloc status -verbose should query volume request 'source'
Browse files Browse the repository at this point in the history
The `nomad alloc status -verbose` command returns a 404 from CSI volumes
because the volume mount block in the task points back to the
`job.group.volume` block. So using the `Name` field to query is the "name" as
seen in the jobspec, and not the name of the volume that we need for querying.

Show both the job-specific name and the volume ID in the resulting output,
which clarifies the difference between the two fields and is more consistent
with the web UI.
  • Loading branch information
tgross committed Nov 13, 2020
1 parent feadd2b commit 5efa9e5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ FOUND:
hostVolumesOutput = append(hostVolumesOutput, "ID|Read Only")
if verbose {
csiVolumesOutput = append(csiVolumesOutput,
"ID|Plugin|Provider|Schedulable|Read Only|Mount Options")
"Name|ID|Plugin|Provider|Schedulable|Read Only|Mount Options")
} else {
csiVolumesOutput = append(csiVolumesOutput, "ID|Read Only")
}
Expand All @@ -800,15 +800,16 @@ FOUND:
if verbose {
// there's an extra API call per volume here so we toggle it
// off with the -verbose flag
vol, _, err := client.CSIVolumes().Info(volReq.Name, nil)
vol, _, err := client.CSIVolumes().Info(volReq.Source, nil)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error retrieving volume info for %q: %s",
volReq.Name, err))
continue
}
csiVolumesOutput = append(csiVolumesOutput,
fmt.Sprintf("%s|%s|%s|%v|%v|%s",
fmt.Sprintf("%s|%s|%s|%s|%v|%v|%s",
volReq.Name,
vol.ID,
vol.PluginID,
vol.Provider,
vol.Schedulable,
Expand Down

0 comments on commit 5efa9e5

Please sign in to comment.