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


##########
server/src/main/java/com/cloud/tags/TaggedResourceManagerImpl.java:
##########
@@ -318,7 +318,11 @@ public Map<String, String> 
getTagsFromResource(ResourceObjectType type, long res
     private void informStoragePoolForVmTags(long vmId, String key, String 
value) {
         List<VolumeVO> volumeVos = volumeDao.findByInstance(vmId);
         for (VolumeVO volume : volumeVos) {
-            DataStore dataStore = 
dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary);
+            Long poolId = volume.getPoolId();
+            if (poolId == null) {
+                continue;
+            }
+            DataStore dataStore = dataStoreMgr.getDataStore(poolId, 
DataStoreRole.Primary);
             if (dataStore == null || !(dataStore.getDriver() instanceof 
PrimaryDataStoreDriver)) {
                 continue;
             }

Review Comment:
   can you combine these and put them in a separate method?
   something like 
   ```
   DataStore dataStore = null;
   try {
       DataStore dataStore = retrieveDatastore(poolId);
   } catch (<local>Exception e) {
      log.info(String.format("no data store found for vm %s with poolId %d", 
vm.getName(), poolId));
       continue;
   }
   ```
   and move the code to new method `DataStore retrieveDatastore(Long poolId) 
{..}`



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

Reply via email to