@@ -63,6 +63,7 @@ func NewControllerServer(ephemeral bool) *controllerServer {
63
63
csi .ControllerServiceCapability_RPC_CREATE_DELETE_SNAPSHOT ,
64
64
csi .ControllerServiceCapability_RPC_LIST_SNAPSHOTS ,
65
65
csi .ControllerServiceCapability_RPC_CLONE_VOLUME ,
66
+ csi .ControllerServiceCapability_RPC_EXPAND_VOLUME ,
66
67
}),
67
68
}
68
69
}
@@ -457,6 +458,42 @@ func (cs *controllerServer) ListSnapshots(ctx context.Context, req *csi.ListSnap
457
458
}, nil
458
459
}
459
460
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 nil , status .Errorf (codes .NotFound , "Could not get volume %s: %v" , volID , err )
482
+ }
483
+
484
+ if exVol .VolSize < capacity {
485
+ exVol .VolSize = capacity
486
+ if err := updateHostpathVolume (volID , exVol ); err != nil {
487
+ return nil , status .Errorf (codes .Internal , "Could not update volume %s: %v" , volID , err )
488
+ }
489
+ }
490
+
491
+ return & csi.ControllerExpandVolumeResponse {
492
+ CapacityBytes : exVol .VolSize ,
493
+ NodeExpansionRequired : true ,
494
+ }, nil
495
+ }
496
+
460
497
func convertSnapshot (snap hostPathSnapshot ) * csi.ListSnapshotsResponse {
461
498
entries := []* csi.ListSnapshotsResponse_Entry {
462
499
{
0 commit comments