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 2021/08/23 19:47:36 UTC

[GitHub] [cloudstack] atrocitytheme opened a new pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

atrocitytheme opened a new pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358


   ### Description
   The recent changes of the main branch enable the global setting to select preferred storage pool and apply its implementation in the VolumeOrchestrator.java in the findStoragePool method
   ```
   Optional<StoragePool> storagePool = getPreferredStoragePool(poolList, vm);
   ```
   But the usage of it has a potential risk of null pointer exception when the vm parameter in findStoragePool is null, current implementation of getPreferredStoragePool doesn't handle such a condition and directly assumes that VM is never null.
   ```
   String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
   ```
   But in one of the implementations in the same class where the findStoragePool is called, it passes vm variable explicitly as null 
   *interface*
   ```
   public VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, UserVm vm) throws StorageUnavailableException;
   ```
   When the VM is creating a volume from a snapshot whose VM or pod is not specified, a null pointer exception might happen due to this null passing of the "VM" variable around line 467 in the VolumeOrchestrator.java
   ```
   while ((pool = findStoragePool(dskCh, dc, pod.first(), null, null, null, poolsToAvoid)) != null) {
                       break;
                   }
   ```
   This PR adds a null handler and returns the default pool when the vm is null
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [x] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [ ] Major
   - [x] Minor
   - [ ] Trivial
   
   
   ### Screenshots (if appropriate):


-- 
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



[GitHub] [cloudstack] rhtyd merged pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
rhtyd merged pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358


   


-- 
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



[GitHub] [cloudstack] atrocitytheme commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
atrocitytheme commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-913249393


   > @atrocitytheme please check the travis failure. might just be related to your fix.
   
   Can anyone run that specific Travis test again? test_affinity_groups_ caught an exception and seems it's not related to this change


-- 
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



[GitHub] [cloudstack] rhtyd commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-914906111


   @blueorangutan package 


-- 
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



[GitHub] [cloudstack] rhtyd commented on a change in pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
rhtyd commented on a change in pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#discussion_r694564087



##########
File path: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
##########
@@ -311,7 +311,10 @@ public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
     }
 
     private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
-        String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
+        String accountStoragePoolUuid = null;
+        if (vm != null) {
+            accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());

Review comment:
       cc @nvazquez @davidjumani @sureshanaparti @weizhouapache - this needs validation, can you check what caused the regression and whether this fix actually fixes the regression or could potentially cause another one?




-- 
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



[GitHub] [cloudstack] rhtyd commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-914930358


   @blueorangutan test 


-- 
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



[GitHub] [cloudstack] atrocitytheme commented on a change in pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
atrocitytheme commented on a change in pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#discussion_r697959408



##########
File path: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
##########
@@ -311,7 +311,10 @@ public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
     }
 
     private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
-        String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
+        String accountStoragePoolUuid = null;
+        if (vm != null) {
+            accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());

Review comment:
       The issue can be caused when a temporary snapshot (which is used only to copy a new VM or volumes) was created, I had this null pointer exception when implementing Clone a Virtual Machine https://github.com/apache/cloudstack/pull/5216/files, and this exception can be fixed after this implementation. 




-- 
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



[GitHub] [cloudstack] nvazquez commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
nvazquez commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-913567668


   The test that failed has run twice, I'll restart that Jenkins job:
   ````
   === TestName: test_02_deploy_vm_anti_affinity_group_fail_on_not_enough_hosts | Status : SUCCESS ===
   === TestName: test_02_deploy_vm_anti_affinity_group_fail_on_not_enough_hosts | Status : EXCEPTION ===
   ````


-- 
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



[GitHub] [cloudstack] blueorangutan commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-904338091


   @atrocitytheme a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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



[GitHub] [cloudstack] ravening commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
ravening commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-913579774


   LGTM


-- 
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



[GitHub] [cloudstack] shwstppr closed pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
shwstppr closed pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358


   


-- 
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



[GitHub] [cloudstack] atrocitytheme commented on a change in pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
atrocitytheme commented on a change in pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#discussion_r697959408



##########
File path: engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java
##########
@@ -311,7 +311,10 @@ public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
     }
 
     private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
-        String accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
+        String accountStoragePoolUuid = null;
+        if (vm != null) {
+            accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());

Review comment:
       The issue can be caused when a temporary snapshot (which is used only to copy a new VM or volumes) was created, I had this null pointer exception when implementing Clone a Virtual Machine https://github.com/apache/cloudstack/pull/5216/files, and this null pointer exception can be fixed after this implementation. 




-- 
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



[GitHub] [cloudstack] blueorangutan commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-914906542


   @rhtyd a Jenkins job has been kicked to build packages. I'll keep you posted as I make progress.


-- 
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



[GitHub] [cloudstack] atrocitytheme commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
atrocitytheme commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-904332053


   > I think it makes sense to move the check to the `getPreferredStoragePool() method`:
   > 
   > ```
   > private Optional<StoragePool> getPreferredStoragePool(List<StoragePool> poolList, VirtualMachine vm) {
   >    String accountStoragePoolUuid = null;
   >    if (vm != null) {
   >       accountStoragePoolUuid = StorageManager.PreferredStoragePool.valueIn(vm.getAccountId());
   >    }
   > ...
   > ```
   > 
   > Then the pool ID specified in the global setting (if set) will be picked instead of the first in the list of pools.
   
   Makes sense, just moved the checker to getPreferredStorge 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-unsubscribe@cloudstack.apache.org

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



[GitHub] [cloudstack] atrocitytheme commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
atrocitytheme commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-904370276


   @blueorangutan test


-- 
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



[GitHub] [cloudstack] blueorangutan commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-904360720


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 989


-- 
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



[GitHub] [cloudstack] blueorangutan commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-914925623


   Packaging result: :heavy_check_mark: el7 :heavy_check_mark: el8 :heavy_check_mark: debian :heavy_check_mark: suse15. SL-JID 1156


-- 
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



[GitHub] [cloudstack] blueorangutan commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-915458532


   <b>Trillian test result (tid-1984)</b>
   Environment: kvm-centos7 (x2), Advanced Networking with Mgmt server 7
   Total time taken: 41728 seconds
   Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr5358-t1984-kvm-centos7.zip
   Smoke tests completed. 89 look OK, 0 have errors
   Only failed tests results shown below:
   
   
   Test | Result | Time (s) | Test File
   --- | --- | --- | ---
   


-- 
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



[GitHub] [cloudstack] DaanHoogland commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
DaanHoogland commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-907849570


   @atrocitytheme please check the travis failure. might just be related to your fix.


-- 
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



[GitHub] [cloudstack] atrocitytheme commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
atrocitytheme commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-904337741


   @blueorangutan package


-- 
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



[GitHub] [cloudstack] nvazquez edited a comment on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
nvazquez edited a comment on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-913567668


   The test that failed has run twice, I'll restart that Travis  job:
   ````
   === TestName: test_02_deploy_vm_anti_affinity_group_fail_on_not_enough_hosts | Status : SUCCESS ===
   === TestName: test_02_deploy_vm_anti_affinity_group_fail_on_not_enough_hosts | Status : EXCEPTION ===
   ````


-- 
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



[GitHub] [cloudstack] shwstppr commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
shwstppr commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-913319590


   @ravening can you please review this


-- 
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



[GitHub] [cloudstack] blueorangutan commented on pull request #5358: Fix potential NullPointerException in findStoragePool (VolumeOrchestrator)

Posted by GitBox <gi...@apache.org>.
blueorangutan commented on pull request #5358:
URL: https://github.com/apache/cloudstack/pull/5358#issuecomment-914930594


   @rhtyd a Trillian-Jenkins test job (centos7 mgmt + kvm-centos7) has been kicked to run smoke tests


-- 
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