You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ml...@apache.org on 2013/04/30 02:16:19 UTC

git commit: updated refs/heads/master to e7f4bfe

Updated Branches:
  refs/heads/master d44e25efb -> e7f4bfe1b


Fix NPE in the planner, in the case that pool ID cannot be looked up in database
when deploying a VM

BUG-ID: CLOUdSTACK-2281
Bugfix-for: 4.2
Reviewed-by: Prachi Damle
Signed-off-by: Marcus Sorensen <ma...@betterservers.com> 1367280909 -0600


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e7f4bfe1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e7f4bfe1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e7f4bfe1

Branch: refs/heads/master
Commit: e7f4bfe1b8277f33e663c31744bc9f30d150fdbf
Parents: d44e25e
Author: Marcus Sorensen <ma...@betterservers.com>
Authored: Mon Apr 29 18:15:09 2013 -0600
Committer: Marcus Sorensen <ma...@betterservers.com>
Committed: Mon Apr 29 18:15:09 2013 -0600

----------------------------------------------------------------------
 server/src/com/cloud/deploy/FirstFitPlanner.java |   40 ++++++++++-------
 1 files changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e7f4bfe1/server/src/com/cloud/deploy/FirstFitPlanner.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/FirstFitPlanner.java b/server/src/com/cloud/deploy/FirstFitPlanner.java
index 2e7e9f6..e8504a9 100755
--- a/server/src/com/cloud/deploy/FirstFitPlanner.java
+++ b/server/src/com/cloud/deploy/FirstFitPlanner.java
@@ -731,37 +731,43 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
             //If the plan specifies a poolId, it means that this VM's ROOT volume is ready and the pool should be reused.
             //In this case, also check if rest of the volumes are ready and can be reused.
             if(plan.getPoolId() != null){
-                s_logger.debug("Volume has pool already allocated, checking if pool can be reused, poolId: "+toBeCreated.getPoolId());
+                s_logger.debug("Volume has pool(" + plan.getPoolId() + ") already allocated, checking if pool can be reused, poolId: "+toBeCreated.getPoolId());
                 List<StoragePool> suitablePools = new ArrayList<StoragePool>();
                 StoragePool pool = null;
                 if(toBeCreated.getPoolId() != null){
+                    s_logger.debug("finding pool by id '" + toBeCreated.getPoolId() + "'");
                     pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(toBeCreated.getPoolId());
                 }else{
+                    s_logger.debug("finding pool by id '" + plan.getPoolId() + "'");
                     pool = (StoragePool)this.dataStoreMgr.getPrimaryDataStore(plan.getPoolId());
                 }
 
-                if(!pool.isInMaintenance()){
-                    if(!avoid.shouldAvoid(pool)){
-                        long exstPoolDcId = pool.getDataCenterId();
-
-                        long exstPoolPodId = pool.getPodId() != null ? pool.getPodId() : -1;
-                        long exstPoolClusterId = pool.getClusterId() != null ? pool.getClusterId() : -1;
-                        if(plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId){
-                            s_logger.debug("Planner need not allocate a pool for this volume since its READY");
-                            suitablePools.add(pool);
-                            suitableVolumeStoragePools.put(toBeCreated, suitablePools);
-                            if (!(toBeCreated.getState() == Volume.State.Allocated || toBeCreated.getState() == Volume.State.Creating)) {
-                                readyAndReusedVolumes.add(toBeCreated);
+                if(pool != null){
+                    if(!pool.isInMaintenance()){
+                        if(!avoid.shouldAvoid(pool)){
+                            long exstPoolDcId = pool.getDataCenterId();
+
+                            long exstPoolPodId = pool.getPodId() != null ? pool.getPodId() : -1;
+                            long exstPoolClusterId = pool.getClusterId() != null ? pool.getClusterId() : -1;
+                            if(plan.getDataCenterId() == exstPoolDcId && plan.getPodId() == exstPoolPodId && plan.getClusterId() == exstPoolClusterId){
+                                s_logger.debug("Planner need not allocate a pool for this volume since its READY");
+                                suitablePools.add(pool);
+                                suitableVolumeStoragePools.put(toBeCreated, suitablePools);
+                                if (!(toBeCreated.getState() == Volume.State.Allocated || toBeCreated.getState() == Volume.State.Creating)) {
+                                    readyAndReusedVolumes.add(toBeCreated);
+                                }
+                                continue;
+                            }else{
+                                s_logger.debug("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume");
                             }
-                            continue;
                         }else{
-                            s_logger.debug("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume");
+                            s_logger.debug("Pool of the volume is in avoid set, need to reallocate a pool for this volume");
                         }
                     }else{
-                        s_logger.debug("Pool of the volume is in avoid set, need to reallocate a pool for this volume");
+                        s_logger.debug("Pool of the volume is in maintenance, need to reallocate a pool for this volume");
                     }
                 }else{
-                    s_logger.debug("Pool of the volume is in maintenance, need to reallocate a pool for this volume");
+                    s_logger.debug("Unable to find pool by provided id");
                 }
             }