@@ -63,6 +63,7 @@ func NewControllerServer(ephemeral bool) *controllerServer {
6363 csi .ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT ,
6464 csi .ControllerServiceCapability_RPC_LIST_SNAPSHOTS ,
6565 csi .ControllerServiceCapability_RPC_CLONE_VOLUME ,
66+ csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ,
6667 }),
6768 }
6869}
@@ -457,6 +458,39 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
457458 }, nil
458459}
459460
461+ func (cs * controllerServer ) ControllerExpandVolume (ctx context.Context , req * csi.ControllerExpandVolumeRequest ) (* csi.ControllerExpandVolumeResponse , error ) {
462+
463+ volID := req .GetVolumeId ()
464+ if len (volID ) == 0 {
465+ return nil , status .Error (codes .InvalidArgument , "Volume ID missing in request" )
466+ }
467+
468+ capRange := req .GetCapacityRange ()
469+ if capRange == nil {
470+ return nil , status .Error (codes .InvalidArgument , "Capacity range not provided" )
471+ }
472+
473+ capacity := int64 (capRange .GetRequiredBytes ())
474+ if capacity >= maxStorageCapacity {
475+ return nil , status .Errorf (codes .OutOfRange , "Requested capacity %d exceeds maximum allowed %d" , capacity , maxStorageCapacity )
476+ }
477+
478+ exVol , err := getVolumeByID (volID )
479+ if err != nil {
480+ // Assume not found error
481+ return & csi.ControllerExpandVolumeResponse {}, status .Errorf (codes .NotFound , "Could not get volume %s: %v" , volID , err )
482+ }
483+
484+ if exVol .VolSize < capacity {
485+ exVol .VolSize = capacity
486+ }
487+
488+ return & csi.ControllerExpandVolumeResponse {
489+ CapacityBytes : exVol .VolSize ,
490+ NodeExpansionRequired : false ,
491+ }, nil
492+ }
493+
460494func convertSnapshot (snap hostPathSnapshot ) * csi.ListSnapshotsResponse {
461495 entries := []* csi.ListSnapshotsResponse_Entry {
462496 {
0 commit comments