CSI: handle per-alloc volumes in `alloc status -verbose` CLI (#12573)
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.
This commit is contained in:
parent
e8b0b91418
commit
f5d8c636c7
|
@ -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`
|
||||||
|
```
|
|
@ -826,9 +826,14 @@ FOUND:
|
||||||
fmt.Sprintf("%s|%v", volReq.Name, *volMount.ReadOnly))
|
fmt.Sprintf("%s|%v", volReq.Name, *volMount.ReadOnly))
|
||||||
case structs.VolumeTypeCSI:
|
case structs.VolumeTypeCSI:
|
||||||
if verbose {
|
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
|
// there's an extra API call per volume here so we toggle it
|
||||||
// off with the -verbose flag
|
// off with the -verbose flag
|
||||||
vol, _, err := client.CSIVolumes().Info(volReq.Source, nil)
|
vol, _, err := client.CSIVolumes().Info(source, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error retrieving volume info for %q: %s",
|
c.Ui.Error(fmt.Sprintf("Error retrieving volume info for %q: %s",
|
||||||
volReq.Name, err))
|
volReq.Name, err))
|
||||||
|
|
Loading…
Reference in New Issue