Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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