nvazquez commented on code in PR #10775:
URL: https://github.com/apache/cloudstack/pull/10775#discussion_r2058623257


##########
plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java:
##########
@@ -455,37 +468,41 @@ private String updateStorPoolVolume(VolumeObject vol, 
ResizeVolumePayload payloa
         }
         SpApiResponse resp = new SpApiResponse();
         if (tier != null || template != null) {
-            Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, 
null, null, null, tier);
-            StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, tags, null, null, template, null, null,
-                    payload.shrinkOk);
-            resp = StorPoolUtil.volumeUpdate(spVolume, conn);
+            resp = updateVolumeByStorPoolQoS(payload, conn, name, tier, 
template);
         } else {
-            long maxIops = payload.newMaxIops == null ? Long.valueOf(0) : 
payload.newMaxIops;
-
-            StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, null, null, maxIops, null, null, null,
-                    payload.shrinkOk);
-            StorPoolUtil.spLog(
-                    "StorpoolPrimaryDataStoreDriverImpl.resize: name=%s, 
uuid=%s, oldSize=%d, newSize=%s, shrinkOk=%s, maxIops=%s",
-                    name, vol.getUuid(), vol.getSize(), payload.newSize, 
payload.shrinkOk, maxIops);
-
-            resp = StorPoolUtil.volumeUpdate(spVolume, conn);
+            resp = updateVolumeByOffering(vol, payload, conn, name);
         }
         if (resp.getError() != null) {
             err = String.format("Could not resize StorPool volume %s. Error: 
%s", name, resp.getError());
-        } else {
-            vol.setSize(payload.newSize);
-            vol.update();
-            if (payload.newMaxIops != null) {
-                VolumeVO volume = volumeDao.findById(vol.getId());
-                volume.setMaxIops(payload.newMaxIops);
-                volumeDao.update(volume.getId(), volume);
-            }
-
-            updateStoragePool(vol.getPoolId(), payload.newSize - 
vol.getSize());
         }
         return err;
     }
 
+    private static SpApiResponse updateVolumeByStorPoolQoS(ResizeVolumePayload 
payload, SpConnectionDesc conn, String name, String tier, String template) {
+
+        SpApiResponse resp;
+        Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, null, 
null, null, tier);
+        StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, tags, null, null, template, null, null,
+                payload.shrinkOk);
+        resp = StorPoolUtil.volumeUpdate(spVolume, conn);

Review Comment:
   Can you add the return on this line and won't need the resp variable?



##########
plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java:
##########
@@ -455,37 +468,41 @@ private String updateStorPoolVolume(VolumeObject vol, 
ResizeVolumePayload payloa
         }
         SpApiResponse resp = new SpApiResponse();
         if (tier != null || template != null) {
-            Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, 
null, null, null, tier);
-            StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, tags, null, null, template, null, null,
-                    payload.shrinkOk);
-            resp = StorPoolUtil.volumeUpdate(spVolume, conn);
+            resp = updateVolumeByStorPoolQoS(payload, conn, name, tier, 
template);
         } else {
-            long maxIops = payload.newMaxIops == null ? Long.valueOf(0) : 
payload.newMaxIops;
-
-            StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, null, null, maxIops, null, null, null,
-                    payload.shrinkOk);
-            StorPoolUtil.spLog(
-                    "StorpoolPrimaryDataStoreDriverImpl.resize: name=%s, 
uuid=%s, oldSize=%d, newSize=%s, shrinkOk=%s, maxIops=%s",
-                    name, vol.getUuid(), vol.getSize(), payload.newSize, 
payload.shrinkOk, maxIops);
-
-            resp = StorPoolUtil.volumeUpdate(spVolume, conn);
+            resp = updateVolumeByOffering(vol, payload, conn, name);
         }
         if (resp.getError() != null) {
             err = String.format("Could not resize StorPool volume %s. Error: 
%s", name, resp.getError());
-        } else {
-            vol.setSize(payload.newSize);
-            vol.update();
-            if (payload.newMaxIops != null) {
-                VolumeVO volume = volumeDao.findById(vol.getId());
-                volume.setMaxIops(payload.newMaxIops);
-                volumeDao.update(volume.getId(), volume);
-            }
-
-            updateStoragePool(vol.getPoolId(), payload.newSize - 
vol.getSize());
         }
         return err;
     }
 
+    private static SpApiResponse updateVolumeByStorPoolQoS(ResizeVolumePayload 
payload, SpConnectionDesc conn, String name, String tier, String template) {
+
+        SpApiResponse resp;
+        Map<String, String> tags = StorPoolHelper.addStorPoolTags(null, null, 
null, null, tier);
+        StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, tags, null, null, template, null, null,
+                payload.shrinkOk);
+        resp = StorPoolUtil.volumeUpdate(spVolume, conn);
+        return resp;
+    }
+
+    private static SpApiResponse updateVolumeByOffering(VolumeObject vol, 
ResizeVolumePayload payload, SpConnectionDesc conn, String name) {
+
+        SpApiResponse resp;
+        long maxIops = payload.newMaxIops == null ? Long.valueOf(0) : 
payload.newMaxIops;
+
+        StorPoolVolumeDef spVolume = new StorPoolVolumeDef(name, 
payload.newSize, null, null, maxIops, null, null, null,
+                payload.shrinkOk);
+        StorPoolUtil.spLog(
+                "StorpoolPrimaryDataStoreDriverImpl.resize: name=%s, uuid=%s, 
oldSize=%d, newSize=%s, shrinkOk=%s, maxIops=%s",
+                name, vol.getUuid(), vol.getSize(), payload.newSize, 
payload.shrinkOk, maxIops);
+
+        resp = StorPoolUtil.volumeUpdate(spVolume, conn);

Review Comment:
   Same for this method



-- 
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: commits-unsubscr...@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to