nvazquez commented on a change in pull request #6005:
URL: https://github.com/apache/cloudstack/pull/6005#discussion_r830739251
##########
File path: server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
##########
@@ -364,7 +383,31 @@ public VolumeVO uploadVolume(UploadVolumeCmd cmd) throws
ResourceAllocationExcep
RegisterVolumePayload payload = new
RegisterVolumePayload(cmd.getUrl(), cmd.getChecksum(), cmd.getFormat());
vol.addPayload(payload);
- volService.registerVolume(vol, store);
+ return registerVolume(vol, store, sizeInGB);
+ }
+
+ VolumeVO registerVolume(VolumeInfo vol, DataStore store, Long sizeInGB ) {
+ VolumeVO volume = _volsDao.findById(vol.getId());
+ try {
+ AsyncCallFuture<VolumeApiResult> future =
volService.registerVolume(vol, store);
+ VolumeApiResult result = future.get();
+ if (result.isFailed()) {
+ s_logger.warn("Failed to register the volume");
+ String details = "";
+ if (result.getResult() != null &&
!result.getResult().isEmpty()) {
+ details = result.getResult();
+ }
+ throw new CloudRuntimeException(details);
+ }
+ if (!Objects.equals(sizeInGB, vol.getSize())) {
Review comment:
Can we add a null check for `sizeInGB` here as well?
##########
File path: server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
##########
@@ -364,7 +383,31 @@ public VolumeVO uploadVolume(UploadVolumeCmd cmd) throws
ResourceAllocationExcep
RegisterVolumePayload payload = new
RegisterVolumePayload(cmd.getUrl(), cmd.getChecksum(), cmd.getFormat());
vol.addPayload(payload);
- volService.registerVolume(vol, store);
+ return registerVolume(vol, store, sizeInGB);
+ }
+
+ VolumeVO registerVolume(VolumeInfo vol, DataStore store, Long sizeInGB ) {
+ VolumeVO volume = _volsDao.findById(vol.getId());
+ try {
+ AsyncCallFuture<VolumeApiResult> future =
volService.registerVolume(vol, store);
+ VolumeApiResult result = future.get();
+ if (result.isFailed()) {
+ s_logger.warn("Failed to register the volume");
+ String details = "";
+ if (result.getResult() != null &&
!result.getResult().isEmpty()) {
+ details = result.getResult();
+ }
+ throw new CloudRuntimeException(details);
+ }
+ if (!Objects.equals(sizeInGB, vol.getSize())) {
+ if (sizeInGB !=null) {
+ volume.setSize(sizeInGB * GiB_TO_BYTES);
Review comment:
At this point is there any other reference that needs to be updated,
like volume_store_ref? Could this cause any issues with GetVolumeStats or not
considered at this volume state?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]