You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2017/11/18 03:45:01 UTC
[cloudstack] branch master updated: CLOUDSTACK-10123: Entity should
use GMT TZ for timestamp values (#2303)
This is an automated email from the ASF dual-hosted git repository.
bhaisaab pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 421f107 CLOUDSTACK-10123: Entity should use GMT TZ for timestamp values (#2303)
421f107 is described below
commit 421f1072d521af20acacfd13eb427f6f0aa02731
Author: Marc-Aurèle Brothier <m...@brothier.org>
AuthorDate: Sat Nov 18 04:44:57 2017 +0100
CLOUDSTACK-10123: Entity should use GMT TZ for timestamp values (#2303)
Depending on the timezone you're running CS (before GMT timezones) you could experience that some jobs are marked as failed since the parent job got a null result despite its child job having successfully done the job. The child job got deleted by the CleanupTask ahead of time, due to a missing datetime conversion to GMT timezone.
Jobs are failing with this message: Job failed with un-handled exception
The fix intends to correct any datetime used in the code that should be using the GMT timezone instead of the local one since all DB datetime should be stored at GMT.
---
.../orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java | 6 ++----
server/src/com/cloud/test/DatabaseConfig.java | 3 ++-
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index f684cbf..ef33356 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -2608,9 +2608,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
s_logger.trace("VM Operation Thread Running");
try {
_workDao.cleanup(VmOpCleanupWait.value());
-
- // TODO. hard-coded to one hour after job has been completed
- final Date cutDate = new Date(new Date().getTime() - 3600000);
+ final Date cutDate = new Date(DateUtil.currentGMTTime().getTime() - VmOpCleanupInterval.value() * 1000);
_workJobDao.expungeCompletedWorkJobs(cutDate);
} catch (final Exception e) {
s_logger.error("VM Operations failed due to ", e);
@@ -2980,7 +2978,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
try {
scanStalledVMInTransitionStateOnDisconnectedHosts();
- final List<VMInstanceVO> instances = _vmDao.findVMInTransition(new Date(new Date().getTime() - AgentManager.Wait.value() * 1000), State.Starting, State.Stopping);
+ final List<VMInstanceVO> instances = _vmDao.findVMInTransition(new Date(DateUtil.currentGMTTime().getTime() - AgentManager.Wait.value() * 1000), State.Starting, State.Stopping);
for (final VMInstanceVO instance : instances) {
final State state = instance.getState();
if (state == State.Stopping) {
diff --git a/server/src/com/cloud/test/DatabaseConfig.java b/server/src/com/cloud/test/DatabaseConfig.java
index f93692c..657eb4e 100644
--- a/server/src/com/cloud/test/DatabaseConfig.java
+++ b/server/src/com/cloud/test/DatabaseConfig.java
@@ -43,6 +43,7 @@ import com.cloud.service.dao.ServiceOfferingDaoImpl;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage.ProvisioningType;
import com.cloud.storage.dao.DiskOfferingDaoImpl;
+import com.cloud.utils.DateUtil;
import com.cloud.utils.PropertiesUtil;
import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.db.DB;
@@ -639,7 +640,7 @@ public class DatabaseConfig {
stmt.setLong(8, 0);
stmt.setString(9, hostAddress);
stmt.setString(10, hostPath);
- stmt.setDate(11, new Date(new java.util.Date().getTime()));
+ stmt.setDate(11, new Date(DateUtil.currentGMTTime().getTime()));
stmt.setLong(12, podId);
stmt.setString(13, Status.Up.toString());
stmt.setLong(14, clusterId);
--
To stop receiving notification emails like this one, please contact
['"commits@cloudstack.apache.org" <co...@cloudstack.apache.org>'].