Skip to content

Commit

Permalink
chore(bors): merge pull request #700
Browse files Browse the repository at this point in the history
700: feat(resize/volume): add openapi spec and REST service interface r=dsharma-dc a=dsharma-dc



Co-authored-by: Diwakar Sharma <[email protected]>
  • Loading branch information
mayastor-bors and dsharma-dc committed Dec 26, 2023
2 parents 39b9be5 + 0f4a40f commit 9d3c484
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 2 deletions.
45 changes: 45 additions & 0 deletions control-plane/rest/openapi-specs/v0_api_spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,38 @@ paths:
$ref: '#/components/responses/ServerError'
security:
- JWT: []
'/volumes/{volume_id}/size':
put:
tags:
- Volumes
operationId: put_volume_size
description: |-
Resize a volume to required size.
parameters:
- in: path
name: volume_id
required: true
schema:
$ref: '#/components/schemas/VolumeId'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ResizeVolumeBody'
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Volume'
'4XX':
$ref: '#/components/responses/ClientError'
'5XX':
$ref: '#/components/responses/ServerError'
security:
- JWT: []
'/volumes/{volume_id}/shutdown_targets':
delete:
tags:
Expand Down Expand Up @@ -2369,6 +2401,19 @@ components:
required:
- snapshot
- volume
ResizeVolumeBody:
example:
size: 104857610
description: Resize Volume Body
type: object
properties:
size:
description: New required size of the volume in bytes
type: integer
format: uint64
minimum: 0
required:
- size
PublishVolumeBody:
example:
node: "io-engine-1"
Expand Down
22 changes: 20 additions & 2 deletions control-plane/rest/service/src/v0/volumes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use stor_port::types::v0::{
openapi::apis::Uuid,
transport::{
DestroyShutdownTargets, DestroyVolume, Filter, GetRebuildRecord, PublishVolume,
RebuildHistory, RebuildJobState, RebuildRecord, RepublishVolume, SetVolumeReplica,
ShareVolume, UnpublishVolume, UnshareVolume, Volume,
RebuildHistory, RebuildJobState, RebuildRecord, RepublishVolume, ResizeVolume,
SetVolumeReplica, ShareVolume, UnpublishVolume, UnshareVolume, Volume,
},
};

Expand Down Expand Up @@ -196,6 +196,24 @@ impl apis::actix_server::Volumes for RestApi {
Ok(share_uri)
}

async fn put_volume_size(
Path(volume_id): Path<Uuid>,
Body(resize_volume_body): Body<models::ResizeVolumeBody>,
) -> Result<models::Volume, RestError<RestJsonError>> {
let volume = client()
.resize(
&ResizeVolume {
uuid: volume_id.into(),
requested_size: resize_volume_body.size as u64,
capacity_limit: None,
},
None,
)
.await?;

Ok(volume.into())
}

async fn put_volume_target(
Path(volume_id): Path<Uuid>,
Body(publish_volume_body): Body<models::PublishVolumeBody>,
Expand Down

0 comments on commit 9d3c484

Please sign in to comment.