mirror of
https://github.com/kemko/nomad.git
synced 2026-01-01 16:05:42 +03:00
csi: volume snapshot list plugin option is required (#12197)
The RPC for listing volume snapshots requires a plugin ID. Update the `volume snapshot list` command to find the specific plugin from the provided prefix.
This commit is contained in:
3
.changelog/12197.txt
Normal file
3
.changelog/12197.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
```release-note:bug
|
||||||
|
csi: Fixed a bug where `volume snapshot list` did not correctly filter by plugin IDs. The `-plugin` parameter is required.
|
||||||
|
```
|
||||||
@@ -22,8 +22,9 @@ func (c *VolumeSnapshotListCommand) Help() string {
|
|||||||
helpText := `
|
helpText := `
|
||||||
Usage: nomad volume snapshot list [-plugin plugin_id]
|
Usage: nomad volume snapshot list [-plugin plugin_id]
|
||||||
|
|
||||||
Display a list of CSI volume snapshots along with their
|
Display a list of CSI volume snapshots for a plugin along
|
||||||
source volume ID as known to the external storage provider.
|
with their source volume ID as known to the external
|
||||||
|
storage provider.
|
||||||
|
|
||||||
When ACLs are enabled, this command requires a token with the
|
When ACLs are enabled, this command requires a token with the
|
||||||
'csi-list-volumes' capability for the plugin's namespace.
|
'csi-list-volumes' capability for the plugin's namespace.
|
||||||
@@ -34,8 +35,8 @@ General Options:
|
|||||||
|
|
||||||
List Options:
|
List Options:
|
||||||
|
|
||||||
-plugin: Display only snapshots managed by a particular plugin. By default
|
-plugin: Display only snapshots managed by a particular plugin. This
|
||||||
this command will query all plugins for their snapshots.
|
parameter is required.
|
||||||
|
|
||||||
-secret
|
-secret
|
||||||
Secrets to pass to the plugin to list snapshots. Accepts multiple
|
Secrets to pass to the plugin to list snapshots. Accepts multiple
|
||||||
@@ -45,7 +46,7 @@ List Options:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *VolumeSnapshotListCommand) Synopsis() string {
|
func (c *VolumeSnapshotListCommand) Synopsis() string {
|
||||||
return "Display a list of volume snapshots"
|
return "Display a list of volume snapshots for plugin"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *VolumeSnapshotListCommand) AutocompleteFlags() complete.Flags {
|
func (c *VolumeSnapshotListCommand) AutocompleteFlags() complete.Flags {
|
||||||
@@ -100,15 +101,17 @@ func (c *VolumeSnapshotListCommand) Run(args []string) int {
|
|||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter by plugin if a plugin ID was passed
|
plugs, _, err := client.CSIPlugins().List(&api.QueryOptions{Prefix: pluginID})
|
||||||
if pluginID != "" {
|
if err != nil {
|
||||||
plugs, _, err := client.CSIPlugins().List(&api.QueryOptions{Prefix: pluginID})
|
c.Ui.Error(fmt.Sprintf("Error querying CSI plugins: %s", err))
|
||||||
if err != nil {
|
return 1
|
||||||
c.Ui.Error(fmt.Sprintf("Error querying CSI plugins: %s", err))
|
}
|
||||||
return 1
|
if len(plugs) == 0 {
|
||||||
}
|
c.Ui.Error(fmt.Sprintf("No plugins(s) with prefix or ID %q found", pluginID))
|
||||||
|
return 1
|
||||||
if len(plugs) > 1 {
|
}
|
||||||
|
if len(plugs) > 1 {
|
||||||
|
if pluginID != plugs[0].ID {
|
||||||
out, err := c.csiFormatPlugins(plugs)
|
out, err := c.csiFormatPlugins(plugs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error formatting: %s", err))
|
||||||
@@ -117,13 +120,8 @@ func (c *VolumeSnapshotListCommand) Run(args []string) int {
|
|||||||
c.Ui.Error(fmt.Sprintf("Prefix matched multiple plugins\n\n%s", out))
|
c.Ui.Error(fmt.Sprintf("Prefix matched multiple plugins\n\n%s", out))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
if len(plugs) == 0 {
|
|
||||||
c.Ui.Error(fmt.Sprintf("No plugins(s) with prefix or ID %q found", pluginID))
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
pluginID = plugs[0].ID
|
|
||||||
}
|
}
|
||||||
|
pluginID = plugs[0].ID
|
||||||
|
|
||||||
secrets := api.CSISecrets{}
|
secrets := api.CSISecrets{}
|
||||||
for _, kv := range secretsArgs {
|
for _, kv := range secretsArgs {
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ func (tc *CSIControllerPluginEBSTest) TestSnapshot(f *framework.F) {
|
|||||||
f.NoError(err, fmt.Sprintf("could not parse output:\n%v", out))
|
f.NoError(err, fmt.Sprintf("could not parse output:\n%v", out))
|
||||||
f.Len(snaps, 1, fmt.Sprintf("could not parse output:\n%v", out))
|
f.Len(snaps, 1, fmt.Sprintf("could not parse output:\n%v", out))
|
||||||
|
|
||||||
out, err = e2e.Command("nomad", "volume", "snapshot", "list")
|
out, err = e2e.Command("nomad", "volume", "snapshot", "list", "-plugin", ebsPluginID)
|
||||||
requireNoErrorElseDump(f, err, "could not list volume snapshots", tc.pluginJobIDs)
|
requireNoErrorElseDump(f, err, "could not list volume snapshots", tc.pluginJobIDs)
|
||||||
f.Contains(out, snaps[0]["ID"],
|
f.Contains(out, snaps[0]["ID"],
|
||||||
fmt.Sprintf("volume snapshot list did not include expected snapshot:\n%v", out))
|
fmt.Sprintf("volume snapshot list did not include expected snapshot:\n%v", out))
|
||||||
|
|||||||
@@ -30,11 +30,10 @@ Nomad.
|
|||||||
## Snapshot List Options
|
## Snapshot List Options
|
||||||
|
|
||||||
- `-plugin`: Display only snapshots managed by a particular [CSI
|
- `-plugin`: Display only snapshots managed by a particular [CSI
|
||||||
plugin][csi_plugin]. By default the `snapshot list` command will query all
|
plugin][csi_plugin]. This flag is required and accepts a plugin ID
|
||||||
plugins for their snapshots. This flag accepts a plugin ID or prefix. If
|
or prefix. If there is an exact match based on the provided plugin,
|
||||||
there is an exact match based on the provided plugin, then that specific
|
then that specific plugin will be queried. Otherwise, a list of
|
||||||
plugin will be queried. Otherwise, a list of matching plugins will be
|
matching plugins will be displayed.
|
||||||
displayed.
|
|
||||||
- `-secret`: Secrets to pass to the plugin to list snapshots. Accepts
|
- `-secret`: Secrets to pass to the plugin to list snapshots. Accepts
|
||||||
multiple flags in the form `-secret key=value`
|
multiple flags in the form `-secret key=value`
|
||||||
|
|
||||||
@@ -54,7 +53,7 @@ snap-67890 vol-fedcba 50GiB 2021-01-04T15:45:00Z true
|
|||||||
|
|
||||||
List volume snapshots with two secret key/value pairs:
|
List volume snapshots with two secret key/value pairs:
|
||||||
```shell-session
|
```shell-session
|
||||||
$ nomad volume snapshot list -secret key1=value1 -secret key2=val2
|
$ nomad volume snapshot list -plugin aws-ebs0 -secret key1=value1 -secret key2=val2
|
||||||
Snapshot ID External ID Size Creation Time Ready?
|
Snapshot ID External ID Size Creation Time Ready?
|
||||||
snap-12345 vol-abcdef 50GiB 2021-01-03T12:15:02Z true
|
snap-12345 vol-abcdef 50GiB 2021-01-03T12:15:02Z true
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user