Repository: cloudstack
Updated Branches:
  refs/heads/master 76a10351a -> 2df190d0e


CLOUDSTACK-8623: CPVM fails to start after MS is restarted during its initial 
start-up process
If SSVM cannot be started then the existing entry is removed and a new SSVM 
gets created. Made similar changes for CPVM as well.
Also cleaned up some log messages in SSVM and CPVM manager code.


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

Branch: refs/heads/master
Commit: 9ec2a6c29c0730d8843bace47ecb608bb7ffcdb2
Parents: 76a1035
Author: Koushik Das <[email protected]>
Authored: Thu Jul 9 17:14:24 2015 +0530
Committer: Koushik Das <[email protected]>
Committed: Tue Jul 14 10:55:19 2015 +0530

----------------------------------------------------------------------
 .../schema/src/com/cloud/vm/ConsoleProxyVO.java |  1 +
 .../src/com/cloud/vm/SecondaryStorageVmVO.java  |  1 +
 .../consoleproxy/ConsoleProxyManagerImpl.java   | 63 +++++++++++---------
 .../SecondaryStorageManagerImpl.java            | 17 +++---
 4 files changed, 44 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec2a6c2/engine/schema/src/com/cloud/vm/ConsoleProxyVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/ConsoleProxyVO.java 
b/engine/schema/src/com/cloud/vm/ConsoleProxyVO.java
index de1d993..fdce20c 100644
--- a/engine/schema/src/com/cloud/vm/ConsoleProxyVO.java
+++ b/engine/schema/src/com/cloud/vm/ConsoleProxyVO.java
@@ -72,6 +72,7 @@ public class ConsoleProxyVO extends VMInstanceVO implements 
ConsoleProxy {
                           long accountId, long userId, int activeSession, 
boolean haEnabled) {
         super(id, serviceOfferingId, name, name, Type.ConsoleProxy, 
templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
         this.activeSession = activeSession;
+        this.dataCenterId = dataCenterId;
     }
 
     protected ConsoleProxyVO() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec2a6c2/engine/schema/src/com/cloud/vm/SecondaryStorageVmVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/SecondaryStorageVmVO.java 
b/engine/schema/src/com/cloud/vm/SecondaryStorageVmVO.java
index 98b1725..9ffc918 100644
--- a/engine/schema/src/com/cloud/vm/SecondaryStorageVmVO.java
+++ b/engine/schema/src/com/cloud/vm/SecondaryStorageVmVO.java
@@ -67,6 +67,7 @@ public class SecondaryStorageVmVO extends VMInstanceVO 
implements SecondaryStora
                                 long domainId, long accountId, long userId, 
Role role, boolean haEnabled) {
         super(id, serviceOfferingId, name, name, Type.SecondaryStorageVm, 
templateId, hypervisorType, guestOSId, domainId, accountId, userId, haEnabled);
         this.role = role;
+        this.dataCenterId = dataCenterId;
     }
 
     protected SecondaryStorageVmVO() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec2a6c2/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java 
b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 476cc8e..d2f6fd2 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -543,9 +543,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase 
implements ConsoleProxy
 
             // For VMs that are in Stopping, Starting, Migrating state, let 
client to wait by returning null
             // as sooner or later, Starting/Migrating state will be transited 
to Running and Stopping will be transited
-            // to
-            // Stopped to allow
-            // Starting of it
+            // to Stopped to allow Starting of it
             s_logger.warn("Console proxy is not in correct state to be 
started: " + proxy.getState());
             return null;
         } catch (StorageUnavailableException e) {
@@ -889,32 +887,32 @@ public class ConsoleProxyManagerImpl extends ManagerBase 
implements ConsoleProxy
 
         ConsoleProxyVO proxy = null;
         String errorString = null;
-        try{
-            if (_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
-                try {
-                    proxy = assignProxyFromStoppedPool(dataCenterId);
-                    if (proxy == null) {
-                        if (s_logger.isInfoEnabled()) {
-                            s_logger.info("No stopped console proxy is 
available, need to allocate a new console proxy");
-                        }
+        try {
+            boolean consoleProxyVmFromStoppedPool = false;
+            proxy = assignProxyFromStoppedPool(dataCenterId);
+            if (proxy == null) {
+                if (s_logger.isInfoEnabled()) {
+                    s_logger.info("No stopped console proxy is available, need 
to allocate a new console proxy");
+                }
 
-                        try {
-                            proxy = startNew(dataCenterId);
-                        } catch (ConcurrentOperationException e) {
-                            s_logger.info("Concurrent Operation caught " + e);
-                        }
-                    } else {
-                        if (s_logger.isInfoEnabled()) {
-                            s_logger.info("Found a stopped console proxy, 
bring it up to running pool. proxy vm id : " + proxy.getId());
-                        }
+                if 
(_allocProxyLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
+                    try {
+                        proxy = startNew(dataCenterId);
+                    } catch (ConcurrentOperationException e) {
+                        s_logger.info("Concurrent operation exception caught " 
+ e);
+                    } finally {
+                        _allocProxyLock.unlock();
+                    }
+                } else {
+                    if (s_logger.isInfoEnabled()) {
+                        s_logger.info("Unable to acquire synchronization lock 
for console proxy vm allocation, wait for next scan");
                     }
-                } finally {
-                    _allocProxyLock.unlock();
                 }
             } else {
                 if (s_logger.isInfoEnabled()) {
-                    s_logger.info("Unable to acquire proxy allocation lock, 
skip for next time");
+                    s_logger.info("Found a stopped console proxy, starting it. 
Vm id : " + proxy.getId());
                 }
+                consoleProxyVmFromStoppedPool = true;
             }
 
             if (proxy != null) {
@@ -927,19 +925,26 @@ public class ConsoleProxyManagerImpl extends ManagerBase 
implements ConsoleProxy
                     }
                     
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT,
 this,
                         new 
ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_UP, dataCenterId, 
proxy.getId(), proxy, null));
+                } else {
+                    if (s_logger.isInfoEnabled()) {
+                        s_logger.info("Unable to start console proxy vm for 
standby capacity, vm id : " + proxyVmId + ", will recycle it and start a new 
one");
+                    }
+
+                    if (consoleProxyVmFromStoppedPool) {
+                        destroyProxy(proxyVmId);
+                    }
                 }
             }
-        }catch (Exception e){
+        } catch (Exception e) {
            errorString = e.getMessage();
            throw e;
-        }finally {
+        } finally {
             // TODO - For now put all the alerts as creation failure. 
Distinguish between creation vs start failure in future.
             // Also add failure reason since startvm masks some of them.
-            if(proxy == null || proxy.getState() != State.Running)
+            if (proxy == null || proxy.getState() != State.Running)
                 
SubscriptionMgr.getInstance().notifySubscribers(ConsoleProxyManager.ALERT_SUBJECT,
 this,
                     new 
ConsoleProxyAlertEventArgs(ConsoleProxyAlertEventArgs.PROXY_CREATE_FAILURE, 
dataCenterId, 0l, null, errorString));
         }
-
     }
 
     public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long 
dataCenterId) {
@@ -1544,14 +1549,14 @@ public class ConsoleProxyManagerImpl extends 
ManagerBase implements ConsoleProxy
 
         if (!reserveStandbyCapacity()) {
             if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Reserving standby capacity is disable, skip 
capacity scan");
+                s_logger.debug("Reserving standby capacity is disabled, skip 
capacity scan");
             }
             return false;
         }
 
         List<StoragePoolVO> upPools = 
_storagePoolDao.listByStatus(StoragePoolStatus.Up);
         if (upPools == null || upPools.size() == 0) {
-            s_logger.debug("Skip capacity scan due to there is no Primary 
Storage UPintenance mode");
+            s_logger.debug("Skip capacity scan as there is no Primary Storage 
in 'Up' state");
             return false;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9ec2a6c2/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
 
b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
index 453a4cb..7524510 100644
--- 
a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
+++ 
b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java
@@ -656,13 +656,13 @@ public class SecondaryStorageManagerImpl extends 
ManagerBase implements Secondar
 
         if (!isSecondaryStorageVmRequired(dataCenterId)) {
             if (s_logger.isDebugEnabled()) {
-                s_logger.debug("Secondary storage vm not required in zone " + 
dataCenterId + " acc. to zone config");
+                s_logger.debug("Secondary storage vm not required in zone " + 
dataCenterId + " according to zone config");
             }
             return;
         }
         SecondaryStorageVmVO secStorageVm = null;
         String errorString = null;
-        try{
+        try {
             boolean secStorageVmFromStoppedPool = false;
             secStorageVm = assignSecStorageVmFromStoppedPool(dataCenterId, 
role);
             if (secStorageVm == null) {
@@ -681,13 +681,13 @@ public class SecondaryStorageManagerImpl extends 
ManagerBase implements Secondar
                     }
                 } else {
                     if (s_logger.isInfoEnabled()) {
-                        s_logger.info("Unable to acquire synchronization lock 
to allocate secStorageVm resource for standby capacity, wait for next scan");
+                        s_logger.info("Unable to acquire synchronization lock 
for secondary storage vm allocation, wait for next scan");
                     }
                     return;
                 }
             } else {
                 if (s_logger.isInfoEnabled()) {
-                    s_logger.info("Found a stopped secondary storage vm, bring 
it up to running pool. secStorageVm vm id : " + secStorageVm.getId());
+                    s_logger.info("Found a stopped secondary storage vm, 
starting it. Vm id : " + secStorageVm.getId());
                 }
                 secStorageVmFromStoppedPool = true;
             }
@@ -704,7 +704,7 @@ public class SecondaryStorageManagerImpl extends 
ManagerBase implements Secondar
                         }
                     } else {
                         if (s_logger.isInfoEnabled()) {
-                            s_logger.info("Unable to acquire synchronization 
lock to start secStorageVm for standby capacity, secStorageVm vm id : " + 
secStorageVm.getId());
+                            s_logger.info("Unable to acquire synchronization 
lock for starting secondary storage vm id : " + secStorageVm.getId());
                         }
                         return;
                     }
@@ -714,8 +714,7 @@ public class SecondaryStorageManagerImpl extends 
ManagerBase implements Secondar
 
                 if (secStorageVm == null) {
                     if (s_logger.isInfoEnabled()) {
-                        s_logger.info("Unable to start secondary storage vm 
for standby capacity, secStorageVm vm Id : " + secStorageVmId +
-                            ", will recycle it and start a new one");
+                        s_logger.info("Unable to start secondary storage vm 
for standby capacity, vm id : " + secStorageVmId + ", will recycle it and start 
a new one");
                     }
 
                     if (secStorageVmFromStoppedPool) {
@@ -729,10 +728,10 @@ public class SecondaryStorageManagerImpl extends 
ManagerBase implements Secondar
                     }
                 }
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             errorString = e.getMessage();
             throw e;
-        }finally{
+        } finally {
             // TODO - For now put all the alerts as creation failure. 
Distinguish between creation vs start failure in future.
             // Also add failure reason since startvm masks some of them.
             if(secStorageVm == null || secStorageVm.getState() != 
State.Running)

Reply via email to