hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.87k stars 1.95k forks source link

Volume snapshot `snapshot_name` seems to be mandatory in the code but optional in the cli #17828

Closed yazdan closed 10 months ago

yazdan commented 1 year ago

I deployed nomad lab on my local machine with 2 node nomad cluster on vms and 3rd vm as Truenas scale.

Nomad version

Nomad v1.5.6
BuildDate 2023-05-19T18:26:13Z
Revision 8af70885c02ab921dedbdf6bc406a1e886866f80

Operating system and Environment details

$ sudo docker images
REPOSITORY                     TAG            IMAGE ID       CREATED         SIZE
democraticcsi/democratic-csi   latest         fded1d6b6dca   3 weeks ago     319MB

$ nomad version
Nomad v1.5.6
BuildDate 2023-05-19T18:26:13Z
Revision 8af70885c02ab921dedbdf6bc406a1e886866f80

$ nomad plugin status
Container Storage Interface
ID       Provider                Controllers Healthy/Expected  Nodes Healthy/Expected
truenas  org.democratic-csi.nfs  1/1                           2/2

$ nomad volume status
Container Storage Interface
ID         Name        Plugin ID  Schedulable  Access Mode
mosquitto  mosquitto:  truenas    true         single-node-writer
test       test        truenas    true         single-node-writer

Issue

I you try to create volume snapshot without providing sanpshot_name it gives an error

$ nomad volume snapshot create test 
Error snapshotting volume: Unexpected response code: 500 (rpc error: 1 error occurred:
    * could not create snapshot: controller create snapshot: rpc error: controller create snapshot: CSI.ControllerCreateSnapshot: missing Name)

but if you provide the sanpshot_name it will create the

Reproduction steps

Enable democratic-csi and try to create a nameless snapshot

Expected Result

Snapshot is created as the sanpshot_name is optional

Actual Result

error

$ nomad volume snapshot create test 
Error snapshotting volume: Unexpected response code: 500 (rpc error: 1 error occurred:
    * could not create snapshot: controller create snapshot: rpc error: controller create snapshot: CSI.ControllerCreateSnapshot: missing Name)

Job file

not applicable

Nomad Server logs

Jul 06 19:39:20 nomad1 nomad[1613]:     2023-07-06T19:39:20.927Z [ERROR] http: request failed: method=PUT path=/v1/volumes/snapshot
Jul 06 19:39:20 nomad1 nomad[1613]:   error=
Jul 06 19:39:20 nomad1 nomad[1613]:   | rpc error: 1 error occurred:
Jul 06 19:39:20 nomad1 nomad[1613]:   | \t* could not create snapshot: controller create snapshot: CSI.ControllerCreateSnapshot: missing Name
Jul 06 19:39:20 nomad1 nomad[1613]:   |
Jul 06 19:39:20 nomad1 nomad[1613]:    code=500

PS: I checked the code and it seems that in the code name is not optional but mandatory https://github.com/hashicorp/nomad/blob/a9f52f540e81ff152574a97c12b011c605d423f8/plugins/csi/plugin.go#L724

yazdan commented 1 year ago

It seems in csi definition this field is not optional https://github.com/container-storage-interface/spec/blob/master/csi.proto#L1131

tgross commented 1 year ago

Thanks for the follow-up @yazdan. This looks like a documentation miss and a bug in the CLI (it should validate the field is set before bothering to send the request).

yazdan commented 1 year ago

@tgross I can submit a PR to correct this. Please let me know

tgross commented 1 year ago

Sure, go for it!

yazdan commented 1 year ago

PR created https://github.com/hashicorp/nomad/pull/17958

tgross commented 10 months ago

Doing some issue cleanup and this was fixed in https://github.com/hashicorp/nomad/pull/17958, which shipped in Nomad 1.6.2