csi: implement ControllerExpandVolume (#18359)

the first half of volume expansion,
this allows a user to update requested capacity
("capacity_min" and "capacity_max") in a volume
specification file, and re-issue either Register
or Create volume commands (or api calls).

the requested capacity will now be "reconciled"
with the current real capacity of the volume,
issuing a ControllerExpandVolume RPC call
to a running controller plugin, if requested
"capacity_min" is higher than the current
capacity on the volume in state.

csi spec:
https://github.com/container-storage-interface/spec/blob/c918b7f/spec.md#controllerexpandvolume

note: this does not yet cover NodeExpandVolume
This commit is contained in:
Daniel Bennett
2023-09-14 14:13:04 -05:00
committed by GitHub
parent 0329393a28
commit c6dbba7cde
17 changed files with 1055 additions and 89 deletions

View File

@@ -54,6 +54,8 @@ type ControllerClient struct {
NextUnpublishVolumeResponse *csipbv1.ControllerUnpublishVolumeResponse
NextValidateVolumeCapabilitiesResponse *csipbv1.ValidateVolumeCapabilitiesResponse
NextCreateVolumeResponse *csipbv1.CreateVolumeResponse
NextExpandVolumeResponse *csipbv1.ControllerExpandVolumeResponse
LastExpandVolumeRequest *csipbv1.ControllerExpandVolumeRequest
NextDeleteVolumeResponse *csipbv1.DeleteVolumeResponse
NextListVolumesResponse *csipbv1.ListVolumesResponse
NextCreateSnapshotResponse *csipbv1.CreateSnapshotResponse
@@ -73,6 +75,8 @@ func (c *ControllerClient) Reset() {
c.NextUnpublishVolumeResponse = nil
c.NextValidateVolumeCapabilitiesResponse = nil
c.NextCreateVolumeResponse = nil
c.NextExpandVolumeResponse = nil
c.LastExpandVolumeRequest = nil
c.NextDeleteVolumeResponse = nil
c.NextListVolumesResponse = nil
c.NextCreateSnapshotResponse = nil
@@ -111,6 +115,11 @@ func (c *ControllerClient) CreateVolume(ctx context.Context, in *csipbv1.CreateV
return c.NextCreateVolumeResponse, c.NextErr
}
func (c *ControllerClient) ControllerExpandVolume(ctx context.Context, in *csipbv1.ControllerExpandVolumeRequest, opts ...grpc.CallOption) (*csipbv1.ControllerExpandVolumeResponse, error) {
c.LastExpandVolumeRequest = in
return c.NextExpandVolumeResponse, c.NextErr
}
func (c *ControllerClient) DeleteVolume(ctx context.Context, in *csipbv1.DeleteVolumeRequest, opts ...grpc.CallOption) (*csipbv1.DeleteVolumeResponse, error) {
return c.NextDeleteVolumeResponse, c.NextErr
}
@@ -140,6 +149,7 @@ type NodeClient struct {
NextUnstageVolumeResponse *csipbv1.NodeUnstageVolumeResponse
NextPublishVolumeResponse *csipbv1.NodePublishVolumeResponse
NextUnpublishVolumeResponse *csipbv1.NodeUnpublishVolumeResponse
NextExpandVolumeResponse *csipbv1.NodeExpandVolumeResponse
}
// NewNodeClient returns a new stub NodeClient
@@ -155,6 +165,7 @@ func (c *NodeClient) Reset() {
c.NextUnstageVolumeResponse = nil
c.NextPublishVolumeResponse = nil
c.NextUnpublishVolumeResponse = nil
c.NextExpandVolumeResponse = nil
}
func (c *NodeClient) NodeGetCapabilities(ctx context.Context, in *csipbv1.NodeGetCapabilitiesRequest, opts ...grpc.CallOption) (*csipbv1.NodeGetCapabilitiesResponse, error) {
@@ -180,3 +191,7 @@ func (c *NodeClient) NodePublishVolume(ctx context.Context, in *csipbv1.NodePubl
func (c *NodeClient) NodeUnpublishVolume(ctx context.Context, in *csipbv1.NodeUnpublishVolumeRequest, opts ...grpc.CallOption) (*csipbv1.NodeUnpublishVolumeResponse, error) {
return c.NextUnpublishVolumeResponse, c.NextErr
}
func (c *NodeClient) NodeExpandVolume(ctx context.Context, in *csipbv1.NodeExpandVolumeRequest, opts ...grpc.CallOption) (*csipbv1.NodeExpandVolumeResponse, error) {
return c.NextExpandVolumeResponse, c.NextErr
}