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 2018/04/20 13:10:40 UTC

[GitHub] DaanHoogland closed pull request #2577: Prevent NPE if guest OS mapping is missing while prioritizing hosts

DaanHoogland closed pull request #2577: Prevent NPE if guest OS mapping is missing while prioritizing hosts
URL: https://github.com/apache/cloudstack/pull/2577
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index 33cee36e192..f4ad478861e 100644
--- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -29,6 +29,8 @@
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
+import com.google.common.base.Strings;
+
 import com.cloud.agent.manager.allocator.HostAllocator;
 import com.cloud.capacity.CapacityManager;
 import com.cloud.capacity.CapacityVO;
@@ -417,6 +419,10 @@ public boolean isVirtualMachineUpgradable(VirtualMachine vm, ServiceOffering off
         // Determine the guest OS category of the template
         String templateGuestOSCategory = getTemplateGuestOSCategory(template);
 
+        if (Strings.isNullOrEmpty(templateGuestOSCategory)) {
+            return hosts;
+        }
+
         List<Host> prioritizedHosts = new ArrayList<Host>();
         List<Host> noHvmHosts = new ArrayList<Host>();
 
@@ -537,6 +543,11 @@ protected String getHostGuestOSCategory(Host host) {
     protected String getTemplateGuestOSCategory(VMTemplateVO template) {
         long guestOSId = template.getGuestOSId();
         GuestOSVO guestOS = _guestOSDao.findById(guestOSId);
+
+        if (guestOS == null) {
+            return null;
+        }
+
         long guestOSCategoryId = guestOS.getCategoryId();
         GuestOSCategoryVO guestOSCategory = _guestOSCategoryDao.findById(guestOSCategoryId);
         return guestOSCategory.getName();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services