@@ -731,37 +731,43 @@ protected Pair<Map<Volume, List<StoragePool>>, List<Volume>> findSuitablePoolsFo
731731 //If the plan specifies a poolId, it means that this VM's ROOT volume is ready and the pool should be reused.
732732 //In this case, also check if rest of the volumes are ready and can be reused.
733733 if (plan .getPoolId () != null ){
734- s_logger .debug ("Volume has pool already allocated, checking if pool can be reused, poolId: " +toBeCreated .getPoolId ());
734+ s_logger .debug ("Volume has pool(" + plan . getPoolId () + ") already allocated, checking if pool can be reused, poolId: " +toBeCreated .getPoolId ());
735735 List <StoragePool > suitablePools = new ArrayList <StoragePool >();
736736 StoragePool pool = null ;
737737 if (toBeCreated .getPoolId () != null ){
738+ s_logger .debug ("finding pool by id '" + toBeCreated .getPoolId () + "'" );
738739 pool = (StoragePool )this .dataStoreMgr .getPrimaryDataStore (toBeCreated .getPoolId ());
739740 }else {
741+ s_logger .debug ("finding pool by id '" + plan .getPoolId () + "'" );
740742 pool = (StoragePool )this .dataStoreMgr .getPrimaryDataStore (plan .getPoolId ());
741743 }
742744
743- if (!pool .isInMaintenance ()){
744- if (!avoid .shouldAvoid (pool )){
745- long exstPoolDcId = pool .getDataCenterId ();
746-
747- long exstPoolPodId = pool .getPodId () != null ? pool .getPodId () : -1 ;
748- long exstPoolClusterId = pool .getClusterId () != null ? pool .getClusterId () : -1 ;
749- if (plan .getDataCenterId () == exstPoolDcId && plan .getPodId () == exstPoolPodId && plan .getClusterId () == exstPoolClusterId ){
750- s_logger .debug ("Planner need not allocate a pool for this volume since its READY" );
751- suitablePools .add (pool );
752- suitableVolumeStoragePools .put (toBeCreated , suitablePools );
753- if (!(toBeCreated .getState () == Volume .State .Allocated || toBeCreated .getState () == Volume .State .Creating )) {
754- readyAndReusedVolumes .add (toBeCreated );
745+ if (pool != null ){
746+ if (!pool .isInMaintenance ()){
747+ if (!avoid .shouldAvoid (pool )){
748+ long exstPoolDcId = pool .getDataCenterId ();
749+
750+ long exstPoolPodId = pool .getPodId () != null ? pool .getPodId () : -1 ;
751+ long exstPoolClusterId = pool .getClusterId () != null ? pool .getClusterId () : -1 ;
752+ if (plan .getDataCenterId () == exstPoolDcId && plan .getPodId () == exstPoolPodId && plan .getClusterId () == exstPoolClusterId ){
753+ s_logger .debug ("Planner need not allocate a pool for this volume since its READY" );
754+ suitablePools .add (pool );
755+ suitableVolumeStoragePools .put (toBeCreated , suitablePools );
756+ if (!(toBeCreated .getState () == Volume .State .Allocated || toBeCreated .getState () == Volume .State .Creating )) {
757+ readyAndReusedVolumes .add (toBeCreated );
758+ }
759+ continue ;
760+ }else {
761+ s_logger .debug ("Pool of the volume does not fit the specified plan, need to reallocate a pool for this volume" );
755762 }
756- continue ;
757763 }else {
758- s_logger .debug ("Pool of the volume does not fit the specified plan , need to reallocate a pool for this volume" );
764+ s_logger .debug ("Pool of the volume is in avoid set , need to reallocate a pool for this volume" );
759765 }
760766 }else {
761- s_logger .debug ("Pool of the volume is in avoid set , need to reallocate a pool for this volume" );
767+ s_logger .debug ("Pool of the volume is in maintenance , need to reallocate a pool for this volume" );
762768 }
763769 }else {
764- s_logger .debug ("Pool of the volume is in maintenance, need to reallocate a pool for this volume " );
770+ s_logger .debug ("Unable to find pool by provided id " );
765771 }
766772 }
767773
0 commit comments