Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSI: respect -verbose flag for allocs in volume status #12153

Merged
merged 1 commit into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/12153.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
csi: Respect the verbose flag in the output of `volume status`
```
2 changes: 1 addition & 1 deletion command/volume_deregister.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func (c *VolumeDeregisterCommand) Run(args []string) int {
if len(vols) > 1 {
if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) {
sort.Slice(vols, func(i, j int) bool { return vols[i].ID < vols[j].ID })
out, err := csiFormatSortedVolumes(vols, fullId)
out, err := csiFormatSortedVolumes(vols)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
return 1
Expand Down
2 changes: 1 addition & 1 deletion command/volume_detach.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *VolumeDetachCommand) Run(args []string) int {
if len(vols) > 1 {
if (volID != vols[0].ID) || (c.allNamespaces() && vols[0].ID == vols[1].ID) {
sort.Slice(vols, func(i, j int) bool { return vols[i].ID < vols[j].ID })
out, err := csiFormatSortedVolumes(vols, fullId)
out, err := csiFormatSortedVolumes(vols)
if err != nil {
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
return 1
Expand Down
5 changes: 5 additions & 0 deletions command/volume_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ func (c *VolumeStatusCommand) Run(args []string) int {
return 1
}

// Truncate alloc and node IDs unless full length is requested
c.length = shortId
if c.verbose {
c.length = fullId
}
c.length = fullId

// Get the HTTP client
Expand Down
6 changes: 3 additions & 3 deletions command/volume_status_csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,16 @@ func (c *VolumeStatusCommand) csiFormatVolumes(vols []*api.CSIVolumeListStub) (s
return out, nil
}

return csiFormatSortedVolumes(vols, c.length)
return csiFormatSortedVolumes(vols)
}

// Format the volumes, assumes that we're already sorted by volume ID
func csiFormatSortedVolumes(vols []*api.CSIVolumeListStub, length int) (string, error) {
func csiFormatSortedVolumes(vols []*api.CSIVolumeListStub) (string, error) {
rows := make([]string, len(vols)+1)
rows[0] = "ID|Name|Plugin ID|Schedulable|Access Mode"
for i, v := range vols {
rows[i+1] = fmt.Sprintf("%s|%s|%s|%t|%s",
limit(v.ID, length),
v.ID,
v.Name,
v.PluginID,
v.Schedulable,
Expand Down