Skip to content

Commit

Permalink
CSI: handle per-alloc volumes in alloc status -verbose CLI (#12573)
Browse files Browse the repository at this point in the history
The Nomad client's `csi_hook` interpolates the alloc suffix with the
volume request's name for CSI volumes with `per_alloc = true`, turning
`example` into `example[1]`. We need to do this same behavior in the
`alloc status` output so that we show the correct volume.
  • Loading branch information
tgross committed Apr 15, 2022
1 parent 04f6b0a commit fd21ceb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changelog/12573.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
csi: Fixed a bug where per-alloc volumes used the incorrect ID when querying for `alloc status -verbose`
```
7 changes: 6 additions & 1 deletion command/alloc_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,9 +826,14 @@ FOUND:
fmt.Sprintf("%s|%v", volReq.Name, *volMount.ReadOnly))
case structs.VolumeTypeCSI:
if verbose {
source := volReq.Source
if volReq.PerAlloc {
source = source + structs.AllocSuffix(alloc.Name)
}

// there's an extra API call per volume here so we toggle it
// off with the -verbose flag
vol, _, err := client.CSIVolumes().Info(volReq.Source, nil)
vol, _, err := client.CSIVolumes().Info(source, nil)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error retrieving volume info for %q: %s",
volReq.Name, err))
Expand Down

0 comments on commit fd21ceb

Please sign in to comment.