diff --git a/.changelog/26642.txt b/.changelog/26642.txt new file mode 100644 index 000000000..630685a75 --- /dev/null +++ b/.changelog/26642.txt @@ -0,0 +1,3 @@ +```release-note:bug +csi: fix EOF error when registering volumes +``` diff --git a/api/csi.go b/api/csi.go index 47f48f478..7177edaab 100644 --- a/api/csi.go +++ b/api/csi.go @@ -503,6 +503,7 @@ type CSIVolumeRegisterRequest struct { type CSIVolumeRegisterResponse struct { Volumes []*CSIVolume Warnings string + QueryMeta } type CSIVolumeDeregisterRequest struct { diff --git a/command/agent/csi_endpoint.go b/command/agent/csi_endpoint.go index 325ce5bb6..d45bfa9ca 100644 --- a/command/agent/csi_endpoint.go +++ b/command/agent/csi_endpoint.go @@ -146,7 +146,7 @@ func (s *HTTPServer) csiVolumeRegister(resp http.ResponseWriter, req *http.Reque setMeta(resp, &out.QueryMeta) - return nil, nil + return out, nil } func (s *HTTPServer) csiVolumeCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error) { diff --git a/command/volume_register_csi.go b/command/volume_register_csi.go index aa5e60551..37ce5137f 100644 --- a/command/volume_register_csi.go +++ b/command/volume_register_csi.go @@ -35,9 +35,11 @@ func (c *VolumeRegisterCommand) csiRegister(client *api.Client, ast *ast.File, o fmt.Sprintf("[bold][yellow]Volume Warnings:\n%s[reset]\n", resp.Warnings))) } - vol = resp.Volumes[0] // note: the command only ever returns 1 volume from the API + for _, vol := range resp.Volumes { + // note: the command only ever returns 1 volume from the API + c.Ui.Output(fmt.Sprintf("Volume %q registered", vol.ID)) + } - c.Ui.Output(fmt.Sprintf("Volume %q registered", vol.ID)) return 0 } diff --git a/nomad/csi_endpoint.go b/nomad/csi_endpoint.go index f2c02b79e..4655fc860 100644 --- a/nomad/csi_endpoint.go +++ b/nomad/csi_endpoint.go @@ -371,6 +371,7 @@ func (v *CSIVolume) Register(args *structs.CSIVolumeRegisterRequest, reply *stru return err } + reply.Volumes = args.Volumes reply.Index = index v.srv.setQueryMeta(&reply.QueryMeta) return nil diff --git a/nomad/structs/csi.go b/nomad/structs/csi.go index 7aee0a04d..150a09e29 100644 --- a/nomad/structs/csi.go +++ b/nomad/structs/csi.go @@ -879,9 +879,10 @@ type CSIVolumeRegisterRequest struct { } type CSIVolumeRegisterResponse struct { + Volumes []*CSIVolume + // Warnings are non-fatal messages from Enterprise policy enforcement Warnings string - QueryMeta }