Skip to content

Commit c8397fd

Browse files
authored
Merge pull request #138 from Leaseweb/feat/volumestats
Refactor node server and mount interface, add volume stats
2 parents a8915cb + ac7cf70 commit c8397fd

File tree

6 files changed

+515
-183
lines changed

6 files changed

+515
-183
lines changed

pkg/driver/controller.go

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
490490
return nil, status.Error(codes.OutOfRange, "Volume size exceeds the limit specified")
491491
}
492492

493-
volume, err := cs.connector.GetVolumeByID(ctx, volumeID)
493+
_, err := cs.connector.GetVolumeByID(ctx, volumeID)
494494
if err != nil {
495495
if errors.Is(err, cloud.ErrNotFound) {
496496
return nil, status.Errorf(codes.NotFound, "Volume %v not found", volumeID)
@@ -499,19 +499,6 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
499499
return nil, status.Error(codes.Internal, fmt.Sprintf("GetVolume failed with error %v", err))
500500
}
501501

502-
if volume.Size >= util.GigaBytesToBytes(volSizeGB) {
503-
// A volume was already resized.
504-
logger.Info("Volume has already been expanded",
505-
"volumeID", volumeID,
506-
"volumeSize", volume.Size,
507-
"volumeSizeRequested", volSizeGB)
508-
509-
return &csi.ControllerExpandVolumeResponse{
510-
CapacityBytes: volume.Size,
511-
NodeExpansionRequired: true,
512-
}, nil
513-
}
514-
515502
// lock out volumeID for clone and delete operation
516503
if err := cs.operationLocks.GetExpandLock(volumeID); err != nil {
517504
logger.Error(err, "failed acquiring expand lock", "volumeID", volumeID)
@@ -530,15 +517,22 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
530517
"volumeSize", volSizeGB,
531518
)
532519

520+
nodeExpansionRequired := true
521+
// Node expansion is not required for raw block volumes.
522+
volCap := req.GetVolumeCapability()
523+
if volCap != nil && volCap.GetBlock() != nil {
524+
nodeExpansionRequired = false
525+
}
526+
533527
return &csi.ControllerExpandVolumeResponse{
534528
CapacityBytes: util.GigaBytesToBytes(volSizeGB),
535-
NodeExpansionRequired: true,
529+
NodeExpansionRequired: nodeExpansionRequired,
536530
}, nil
537531
}
538532

539533
func (cs *controllerServer) ControllerGetCapabilities(ctx context.Context, req *csi.ControllerGetCapabilitiesRequest) (*csi.ControllerGetCapabilitiesResponse, error) {
540534
logger := klog.FromContext(ctx)
541-
logger.V(6).Info("ControllerExpandVolume: called", "args", protosanitizer.StripSecrets(*req))
535+
logger.V(6).Info("ControllerGetCapabilities: called", "args", protosanitizer.StripSecrets(*req))
542536

543537
resp := &csi.ControllerGetCapabilitiesResponse{
544538
Capabilities: []*csi.ControllerServiceCapability{

0 commit comments

Comments
 (0)