Skip to content

Commit

Permalink
csi: fix CLI panic when formatting volume status with -verbose flag
Browse files Browse the repository at this point in the history
When the `-verbose` flag is passed to the `nomad volume status` command, we
hit a code path where the rows of text to be formatted were not initialized
correctly, resulting in a panic in the CLI.
  • Loading branch information
tgross committed Jun 25, 2021
1 parent 09bd336 commit 529cb36
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions command/volume_status_csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,17 @@ NEXT_PLUGIN:
// rather than an empty list
continue NEXT_PLUGIN
}
rows := []string{}
rows[0] = "External ID|Condition|Nodes"
for i, v := range externalList.Volumes {
rows := []string{"External ID|Condition|Nodes"}
for _, v := range externalList.Volumes {
condition := "OK"
if v.IsAbnormal {
condition = fmt.Sprintf("Abnormal (%v)", v.Status)
}

rows[i+1] = fmt.Sprintf("%s|%s|%s",
rows = append(rows, fmt.Sprintf("%s|%s|%s",
limit(v.ExternalID, c.length),
limit(condition, 20),
strings.Join(v.PublishedExternalNodeIDs, ","),
)
))
}
c.Ui.Output(formatList(rows))

Expand Down

0 comments on commit 529cb36

Please sign in to comment.