Skip to content

Commit 485356c

Browse files
csi: fix volume registration error (#26642)
1 parent 5f34867 commit 485356c

6 files changed

Lines changed: 12 additions & 4 deletions

File tree

.changelog/26642.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
csi: fix EOF error when registering volumes
3+
```

api/csi.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ type CSIVolumeRegisterRequest struct {
503503
type CSIVolumeRegisterResponse struct {
504504
Volumes []*CSIVolume
505505
Warnings string
506+
QueryMeta
506507
}
507508

508509
type CSIVolumeDeregisterRequest struct {

command/agent/csi_endpoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (s *HTTPServer) csiVolumeRegister(resp http.ResponseWriter, req *http.Reque
146146

147147
setMeta(resp, &out.QueryMeta)
148148

149-
return nil, nil
149+
return out, nil
150150
}
151151

152152
func (s *HTTPServer) csiVolumeCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error) {

command/volume_register_csi.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,11 @@ func (c *VolumeRegisterCommand) csiRegister(client *api.Client, ast *ast.File, o
3535
fmt.Sprintf("[bold][yellow]Volume Warnings:\n%s[reset]\n", resp.Warnings)))
3636
}
3737

38-
vol = resp.Volumes[0] // note: the command only ever returns 1 volume from the API
38+
for _, vol := range resp.Volumes {
39+
// note: the command only ever returns 1 volume from the API
40+
c.Ui.Output(fmt.Sprintf("Volume %q registered", vol.ID))
41+
}
3942

40-
c.Ui.Output(fmt.Sprintf("Volume %q registered", vol.ID))
4143
return 0
4244
}
4345

nomad/csi_endpoint.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ func (v *CSIVolume) Register(args *structs.CSIVolumeRegisterRequest, reply *stru
371371
return err
372372
}
373373

374+
reply.Volumes = args.Volumes
374375
reply.Index = index
375376
v.srv.setQueryMeta(&reply.QueryMeta)
376377
return nil

nomad/structs/csi.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,10 @@ type CSIVolumeRegisterRequest struct {
879879
}
880880

881881
type CSIVolumeRegisterResponse struct {
882+
Volumes []*CSIVolume
883+
882884
// Warnings are non-fatal messages from Enterprise policy enforcement
883885
Warnings string
884-
885886
QueryMeta
886887
}
887888

0 commit comments

Comments
 (0)