You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ra...@apache.org on 2015/10/05 08:07:49 UTC
[1/3] git commit: updated refs/heads/master to 99059e2
Repository: cloudstack
Updated Branches:
refs/heads/master 78f74295e -> 99059e221
CLOUDSTACK-8848: ensure power state is up to date when handling missing VMs in powerReport
There 2 things which has been changed.
* We look on power_state_update_time instead of update_time. Didn't make sense to me at all to look at update_time.
* Due DB update optimisation, powerState will only be updated if < MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT. That is why we can not rely on these information unless we make sure these are up to date.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/542880ae
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/542880ae
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/542880ae
Branch: refs/heads/master
Commit: 542880ae76c5e6eefbf61d42364e881495e6f3af
Parents: 3ded3e9
Author: Rene Moser <re...@apache.org>
Authored: Thu Sep 24 21:10:26 2015 +0200
Committer: Rene Moser <re...@apache.org>
Committed: Sun Sep 27 22:14:03 2015 +0200
----------------------------------------------------------------------
.../src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java | 9 ++++++++-
engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java | 2 ++
engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java | 6 ++++++
3 files changed, 16 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/542880ae/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
index d3dcdec..19ed71c 100644
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
@@ -111,7 +111,14 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat
for (VMInstanceVO instance : vmsThatAreMissingReport) {
- Date vmStateUpdateTime = instance.getUpdateTime();
+ // Make sure powerState is up to date for missing VMs
+ if (!_instanceDao.isPowerStateUpToDate(instance.getId())) {
+ s_logger.warn("Detected missing VM but power state is outdated, wait for another process report run for VM id: " + instance.getId());
+ _instanceDao.resetVmPowerStateTracking(instance.getId());
+ continue;
+ }
+
+ Date vmStateUpdateTime = instance.getPowerStateUpdateTime();
if (vmStateUpdateTime == null) {
s_logger.warn("VM state was updated but update time is null?! vm id: " + instance.getId());
vmStateUpdateTime = currentTime;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/542880ae/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
index 1d522dc..8d457fa 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDao.java
@@ -138,4 +138,6 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
HashMap<String, Long> countVgpuVMs(Long dcId, Long podId, Long clusterId);
VMInstanceVO findVMByHostNameInZone(String hostName, long zoneId);
+
+ boolean isPowerStateUpToDate(long instanceId);
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/542880ae/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index 427c534..33583c8 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -805,6 +805,12 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
}
@Override
+ public boolean isPowerStateUpToDate(final long instanceId) {
+ VMInstanceVO instance = findById(instanceId);
+ return instance.getPowerStateUpdateCount() < MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT;
+ }
+
+ @Override
public void resetVmPowerStateTracking(final long instanceId) {
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
[3/3] git commit: updated refs/heads/master to 99059e2
Posted by ra...@apache.org.
Merge pull request #909 from DaanHoogland/RESMO-CLOUDSTACK-8848
CLOUDSTACK-8848 ensure power state is up to date for missing PowerState handlingadded a null guard to @resmo's #885 A unit test or two would be nice as well but as this is a blocker I want to get it to review asap.
@koushik-das @wilderrodrigues @anshul1886 @karuturi @remibergsma you all commented on the original, please have a look. @bhaisaab welcome to comment as well.
* pr/909:
CLOUDSTACK-8848: added null pointer guard to new public method
CLOUDSTACK-8848: ensure power state is up to date when handling missing VMs in powerReport
Signed-off-by: Rajani Karuturi <ra...@citrix.com>
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/99059e22
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/99059e22
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/99059e22
Branch: refs/heads/master
Commit: 99059e2212833a13428bef93195e31a2641c644e
Parents: 78f7429 b128e56
Author: Rajani Karuturi <ra...@citrix.com>
Authored: Mon Oct 5 11:36:13 2015 +0530
Committer: Rajani Karuturi <ra...@citrix.com>
Committed: Mon Oct 5 11:36:15 2015 +0530
----------------------------------------------------------------------
.../cloud/vm/VirtualMachinePowerStateSyncImpl.java | 16 ++++++++++++++--
.../schema/src/com/cloud/vm/dao/VMInstanceDao.java | 2 ++
.../src/com/cloud/vm/dao/VMInstanceDaoImpl.java | 9 +++++++++
3 files changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
[2/3] git commit: updated refs/heads/master to 99059e2
Posted by ra...@apache.org.
CLOUDSTACK-8848: added null pointer guard to new public method
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b128e567
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b128e567
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b128e567
Branch: refs/heads/master
Commit: b128e567c4eacf4d22e6a8c0d6888c297c7fb726
Parents: 542880a
Author: Daan Hoogland <da...@onecht.net>
Authored: Fri Oct 2 11:42:42 2015 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Mon Oct 5 07:27:28 2015 +0200
----------------------------------------------------------------------
.../com/cloud/vm/VirtualMachinePowerStateSyncImpl.java | 13 +++++++++----
.../schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java | 3 +++
2 files changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b128e567/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
index 19ed71c..3b9d6f5 100644
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachinePowerStateSyncImpl.java
@@ -24,13 +24,13 @@ import java.util.Map;
import javax.inject.Inject;
import org.apache.log4j.Logger;
-
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.messagebus.MessageBus;
import org.apache.cloudstack.framework.messagebus.PublishScope;
import com.cloud.agent.api.HostVmStateReportEntry;
import com.cloud.utils.DateUtil;
+import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.dao.VMInstanceDao;
public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStateSync {
@@ -112,9 +112,14 @@ public class VirtualMachinePowerStateSyncImpl implements VirtualMachinePowerStat
for (VMInstanceVO instance : vmsThatAreMissingReport) {
// Make sure powerState is up to date for missing VMs
- if (!_instanceDao.isPowerStateUpToDate(instance.getId())) {
- s_logger.warn("Detected missing VM but power state is outdated, wait for another process report run for VM id: " + instance.getId());
- _instanceDao.resetVmPowerStateTracking(instance.getId());
+ try {
+ if (!_instanceDao.isPowerStateUpToDate(instance.getId())) {
+ s_logger.warn("Detected missing VM but power state is outdated, wait for another process report run for VM id: " + instance.getId());
+ _instanceDao.resetVmPowerStateTracking(instance.getId());
+ continue;
+ }
+ } catch (CloudRuntimeException e) {
+ s_logger.warn("Checked for missing powerstate of a none existing vm", e);
continue;
}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b128e567/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
index 33583c8..d58ff9e 100644
--- a/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/VMInstanceDaoImpl.java
@@ -807,6 +807,9 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
@Override
public boolean isPowerStateUpToDate(final long instanceId) {
VMInstanceVO instance = findById(instanceId);
+ if(instance == null) {
+ throw new CloudRuntimeException("checking power state update count on non existing instance " + instanceId);
+ }
return instance.getPowerStateUpdateCount() < MAX_CONSECUTIVE_SAME_STATE_UPDATE_COUNT;
}