@@ -280,6 +280,7 @@ func (cs *controllerServer) ControllerUnpublishVolume(ctx context.Context, req *
280
280
}
281
281
282
282
func (cs * controllerServer ) ListVolumes (ctx context.Context , req * csi.ListVolumesRequest ) (* csi.ListVolumesResponse , error ) {
283
+ klog .V (4 ).Infof ("ListVolumes: called with %+#v request" , req )
283
284
284
285
if req .MaxEntries < 0 {
285
286
return nil , status .Error (codes .InvalidArgument , fmt .Sprintf (
@@ -296,7 +297,7 @@ func (cs *controllerServer) ListVolumes(ctx context.Context, req *csi.ListVolume
296
297
return nil , status .Error (codes .Internal , fmt .Sprintf ("ListVolumes failed with error %v" , err ))
297
298
}
298
299
299
- var ventries []* csi.ListVolumesResponse_Entry
300
+ ventries := make ( []* csi.ListVolumesResponse_Entry , 0 , len ( vlist ))
300
301
for _ , v := range vlist {
301
302
ventry := csi.ListVolumesResponse_Entry {
302
303
Volume : & csi.Volume {
@@ -306,13 +307,16 @@ func (cs *controllerServer) ListVolumes(ctx context.Context, req *csi.ListVolume
306
307
}
307
308
308
309
status := & csi.ListVolumesResponse_VolumeStatus {}
310
+ status .PublishedNodeIds = make ([]string , 0 , len (v .Attachments ))
309
311
for _ , attachment := range v .Attachments {
310
312
status .PublishedNodeIds = append (status .PublishedNodeIds , attachment .ServerID )
311
313
}
312
314
ventry .Status = status
313
315
314
316
ventries = append (ventries , & ventry )
315
317
}
318
+
319
+ klog .V (4 ).Infof ("ListVolumes: completed with %d entries and %q next token" , len (ventries ), nextPageToken )
316
320
return & csi.ListVolumesResponse {
317
321
Entries : ventries ,
318
322
NextToken : nextPageToken ,
@@ -478,7 +482,7 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
478
482
return nil , status .Errorf (codes .Internal , "ListSnapshots failed with error %v" , err )
479
483
}
480
484
481
- var sentries []* csi.ListSnapshotsResponse_Entry
485
+ sentries := make ( []* csi.ListSnapshotsResponse_Entry , 0 , len ( slist ))
482
486
for _ , v := range slist {
483
487
ctime := timestamppb .New (v .CreatedAt )
484
488
if err := ctime .CheckValid (); err != nil {
@@ -582,6 +586,7 @@ func (cs *controllerServer) ControllerGetVolume(ctx context.Context, req *csi.Co
582
586
}
583
587
584
588
status := & csi.ControllerGetVolumeResponse_VolumeStatus {}
589
+ status .PublishedNodeIds = make ([]string , 0 , len (volume .Attachments ))
585
590
for _ , attachment := range volume .Attachments {
586
591
status .PublishedNodeIds = append (status .PublishedNodeIds , attachment .ServerID )
587
592
}
0 commit comments