You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2022/09/06 11:42:37 UTC

[GitHub] [cloudstack] DaanHoogland commented on a diff in pull request #6524: [GSOC] Oauth2 google idp

DaanHoogland commented on code in PR #6524:
URL: https://github.com/apache/cloudstack/pull/6524#discussion_r963508664


##########
.github/workflows/codecov.yml:
##########
@@ -0,0 +1,50 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+name: Coverage Check

Review Comment:
   this file seems out of scope. Is the intention that a third coverage automaton is added to the project or that the bahaviour of the existing bots are somehow adjusted?



##########
api/src/main/java/org/apache/cloudstack/api/command/admin/config/UpdateCfgCmd.java:
##########
@@ -50,7 +50,7 @@ public class UpdateCfgCmd extends BaseCmd {
     @Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the configuration")
     private String cfgName;
 
-    @Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, description = "the value of the configuration", length = 4095)
+    @Parameter(name = ApiConstants.VALUE, type = CommandType.STRING, description = "the value of the configuration", length = 4096)

Review Comment:
   makes sense, but have you considdered null-termination issues?



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1309,24 +1363,29 @@ public boolean storageMigration(VirtualMachineProfile vm, Map<Volume, StoragePoo
         for (Map.Entry<Volume, StoragePool> entry : volumeToPool.entrySet()) {
             Volume volume = entry.getKey();
             StoragePool pool = entry.getValue();
+
+            String volumeToString = getVolumeIdentificationInfos(volume);
+            String poolToString = getReflectOnlySelectedFields(pool);
+
             if (volume.getState() != Volume.State.Ready) {
-                s_logger.debug("volume: " + volume.getId() + " is in " + volume.getState() + " state");
-                throw new CloudRuntimeException("volume: " + volume.getId() + " is in " + volume.getState() + " state");
+                String msg = String.format("Volume [%s] is in [%s] state.", volumeToString, volume.getState());
+                s_logger.error(msg);
+                throw new CloudRuntimeException(msg);
             }
 
             if (volume.getPoolId() == pool.getId()) {
-                s_logger.debug("volume: " + volume.getId() + " is on the same storage pool: " + pool.getId());
+                s_logger.debug(String.format("Volume [%s] already is on the elected storage pool [%s].", volumeToString, poolToString));

Review Comment:
   ```suggestion
                   if (s_logger.isDebugEnabled()) {
                       s_logger.debug(String.format("Volume [%s] already is on the elected storage pool [%s].", volumeToString, poolToString));
                   }
   ```



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1790,14 +1875,21 @@ private void cleanupVolumeDuringMigrationFailure(Long volumeId, Long destPoolId)
         }
 
         VolumeVO volume = _volsDao.findById(volumeId);
+
+        String destPoolToString = getReflectOnlySelectedFields(destPool);
+        String volumeToString = getReflectOnlySelectedFields(volume);
+
         if (volume.getState() == Volume.State.Migrating) {
             VolumeVO duplicateVol = _volsDao.findByPoolIdName(destPoolId, volume.getName());
+
             if (duplicateVol != null) {
-                s_logger.debug("Remove volume " + duplicateVol.getId() + " on storage pool " + destPoolId);
+                String duplicateVolToString = getReflectOnlySelectedFields(duplicateVol);
+
+                s_logger.debug(String.format("Removing volume [%s] from storage pool [%s] because it's duplicated.", duplicateVolToString, destPoolToString));

Review Comment:
   ```suggestion
                   if (s_logger.isDebugEnabled()) {
                       s_logger.debug(String.format("Removing volume [%s] from storage pool [%s] because it's duplicated.", duplicateVolToString, destPoolToString));
                   }
   ```



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1807,8 +1899,11 @@ private void cleanupVolumeDuringMigrationFailure(Long volumeId, Long destPoolId)
     private void cleanupVolumeDuringSnapshotFailure(Long volumeId, Long snapshotId) {
         _snapshotSrv.cleanupVolumeDuringSnapshotFailure(volumeId, snapshotId);
         VolumeVO volume = _volsDao.findById(volumeId);
+
+        String volumeToString = getReflectOnlySelectedFields(volume);
+
         if (volume.getState() == Volume.State.Snapshotting) {
-            s_logger.debug("change volume state back to Ready: " + volume.getId());
+            s_logger.debug(String.format("Changing volume [%s] state back to Ready.", volumeToString));

Review Comment:
   ```suggestion
               if (s_logger.isDebugEnabled()) {
                   s_logger.debug(String.format("Changing volume [%s] state back to Ready.", volumeToString));
               }
   ```



##########
engine/schema/src/main/resources/META-INF/db/schema-41700to41710.sql:
##########
@@ -20,4 +20,112 @@
 --;
 
 UPDATE `cloud`.`configuration` SET `value` = 'false' WHERE `name` = 'network.disable.rpfilter' AND `value` != 'true';
-UPDATE `cloud`.`configuration` SET `value` = 'false' WHERE `name` = 'consoleproxy.disable.rpfilter' AND `value` != 'true';
\ No newline at end of file
+UPDATE `cloud`.`configuration` SET `value` = 'false' WHERE `name` = 'consoleproxy.disable.rpfilter' AND `value` != 'true';
+

Review Comment:
   why changes for the DB v 4.17.1 in this PR?



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1554,17 +1629,20 @@ private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, VirtualMachinePro
                         if (!primaryDataStore.isManaged()) {
                             templ = tmplFactory.getReadyBypassedTemplateOnPrimaryStore(templateId, destPool.getId(), dest.getHost().getId());
                         } else {
-                            s_logger.debug("Direct download template: " + templateId + " on host: " + dest.getHost().getId() + " and copy to the managed storage pool: " + destPool.getId());
+                            s_logger.debug(String.format("Directly downloading template [%s] on host [%s] and copying it to the managed storage pool [%s].",

Review Comment:
   ```suggestion
                               if (s_logger.isDebugEnabled()) {
                                   s_logger.debug(String.format("Directly downloading template [%s] on host [%s] and copying it to the managed storage pool [%s].",
                               }
   ```



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1129,20 +1171,21 @@ public void cleanupVolumes(long vmId) throws ConcurrentOperationException {
             @Override
             public void doInTransactionWithoutResult(TransactionStatus status) {
                 for (VolumeVO vol : volumesForVm) {
+                    String volumeToString = getReflectOnlySelectedFields(vol);
+
                     if (vol.getVolumeType().equals(Type.ROOT)) {
                         // Destroy volume if not already destroyed
                         boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy || vol.getState() == Volume.State.Expunged || vol.getState() == Volume.State.Expunging);
                         if (!volumeAlreadyDestroyed) {
                             volService.destroyVolume(vol.getId());
                         } else {
-                            s_logger.debug("Skipping destroy for the volume " + vol + " as its in state " + vol.getState().toString());
+                            s_logger.debug(String.format("Skipping destroy for the volume [%s] as it is in [%s] state.", volumeToString, vol.getState().toString()));

Review Comment:
   ```suggestion
                               if (s_logger.isDebugEnabled()) {
                                   s_logger.debug(String.format("Skipping destroy for the volume [%s] as it is in [%s] state.", volumeToString, vol.getState().toString()));
                               }
   ```



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1790,14 +1875,21 @@ private void cleanupVolumeDuringMigrationFailure(Long volumeId, Long destPoolId)
         }
 
         VolumeVO volume = _volsDao.findById(volumeId);
+
+        String destPoolToString = getReflectOnlySelectedFields(destPool);
+        String volumeToString = getReflectOnlySelectedFields(volume);
+
         if (volume.getState() == Volume.State.Migrating) {
             VolumeVO duplicateVol = _volsDao.findByPoolIdName(destPoolId, volume.getName());
+
             if (duplicateVol != null) {
-                s_logger.debug("Remove volume " + duplicateVol.getId() + " on storage pool " + destPoolId);
+                String duplicateVolToString = getReflectOnlySelectedFields(duplicateVol);
+
+                s_logger.debug(String.format("Removing volume [%s] from storage pool [%s] because it's duplicated.", duplicateVolToString, destPoolToString));
                 _volsDao.remove(duplicateVol.getId());
             }
 
-            s_logger.debug("change volume state to ready from migrating in case migration failure for vol: " + volumeId);
+            s_logger.debug(String.format("Changing volume [%s] state from Migrating to Ready in case of migration failure.", volumeToString));

Review Comment:
   ```suggestion
               if (s_logger.isDebugEnabled()) {
                   s_logger.debug(String.format("Changing volume [%s] state from Migrating to Ready in case of migration failure.", volumeToString));
               }
   ```



##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -1971,18 +2075,20 @@ public DiskProfile importVolume(Type type, String name, DiskOffering offering, L
     @Override
     public void unmanageVolumes(long vmId) {
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Unmanaging storage for vm: " + vmId);
+            s_logger.debug(String.format("Unmanaging storage for VM [%s].", _userVmDao.findById(vmId)));
         }
         final List<VolumeVO> volumesForVm = _volsDao.findByInstance(vmId);
 
         Transaction.execute(new TransactionCallbackNoReturn() {
             @Override
             public void doInTransactionWithoutResult(TransactionStatus status) {
                 for (VolumeVO vol : volumesForVm) {
+                    String volToString = getReflectOnlySelectedFields(vol);
+
                     boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy || vol.getState() == Volume.State.Expunged
                             || vol.getState() == Volume.State.Expunging);
                     if (volumeAlreadyDestroyed) {
-                        s_logger.debug("Skipping destroy for the volume " + vol + " as its in state " + vol.getState().toString());
+                        s_logger.debug(String.format("Skipping Destroy for the volume [%s] as it is in [%s] state.", volToString, vol.getState().toString()));

Review Comment:
   ```suggestion
                           if (s_logger.isDebugEnabled()) {
                               s_logger.debug(String.format("Skipping Destroy for the volume [%s] as it is in [%s] state.", volToString, vol.getState().toString()));
                           }
   ```



-- 
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-unsubscribe@cloudstack.apache.org

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