From 9ef76f7f2f22db1abb3958a55bbf8b855c54a649 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Fri, 13 Nov 2020 15:45:52 -0500 Subject: [PATCH] csi: alloc status -verbose should query volume request 'source' 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. --- command/alloc_status.go | 7 ++++--- command/alloc_status_test.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/command/alloc_status.go b/command/alloc_status.go index 2dc8947a36f..0c9e697b1fe 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -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") } @@ -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, diff --git a/command/alloc_status_test.go b/command/alloc_status_test.go index df921c7cc73..c875a5bc0ab 100644 --- a/command/alloc_status_test.go +++ b/command/alloc_status_test.go @@ -491,7 +491,7 @@ func TestAllocStatusCommand_CSIVolumes(t *testing.T) { vol0: { Name: vol0, Type: structs.VolumeTypeCSI, - Source: "/tmp/vol0", + Source: vol0, }, } job.TaskGroups[0].Tasks[0].VolumeMounts = []*structs.VolumeMount{