Skip to content

Commit

Permalink
refactor: Improve node <-> mount interface
Browse files Browse the repository at this point in the history
fix: Handling of block devices
feat: Add volume statistics
  • Loading branch information
hrak committed Jul 1, 2024
1 parent a8915cb commit b84309a
Show file tree
Hide file tree
Showing 4 changed files with 483 additions and 190 deletions.
26 changes: 10 additions & 16 deletions pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
return nil, status.Error(codes.OutOfRange, "Volume size exceeds the limit specified")
}

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

if volume.Size >= util.GigaBytesToBytes(volSizeGB) {
// A volume was already resized.
logger.Info("Volume has already been expanded",
"volumeID", volumeID,
"volumeSize", volume.Size,
"volumeSizeRequested", volSizeGB)

return &csi.ControllerExpandVolumeResponse{
CapacityBytes: volume.Size,
NodeExpansionRequired: true,
}, nil
}

// lock out volumeID for clone and delete operation
if err := cs.operationLocks.GetExpandLock(volumeID); err != nil {
logger.Error(err, "failed acquiring expand lock", "volumeID", volumeID)
Expand All @@ -530,15 +517,22 @@ func (cs *controllerServer) ControllerExpandVolume(ctx context.Context, req *csi
"volumeSize", volSizeGB,
)

nodeExpansionRequired := true
// Node expansion is not required for raw block volumes.
volCap := req.GetVolumeCapability()
if volCap != nil && volCap.GetBlock() != nil {
nodeExpansionRequired = false
}

return &csi.ControllerExpandVolumeResponse{
CapacityBytes: util.GigaBytesToBytes(volSizeGB),
NodeExpansionRequired: true,
NodeExpansionRequired: nodeExpansionRequired,
}, nil
}

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

resp := &csi.ControllerGetCapabilitiesResponse{
Capabilities: []*csi.ControllerServiceCapability{
Expand Down
Loading

0 comments on commit b84309a

Please sign in to comment.