|
@@ -24,25 +24,25 @@ public class ScheduledTasks {
|
|
|
private final DeploymentMapper deploymentMapper;
|
|
private final DeploymentMapper deploymentMapper;
|
|
|
private final PipelineMapper pipelineMapper;
|
|
private final PipelineMapper pipelineMapper;
|
|
|
|
|
|
|
|
- @Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
|
- public void purgeZombieDeployments() {
|
|
|
|
|
|
|
+// @Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
|
+// public void purgeZombieDeployments() {
|
|
|
// final long ONE_DAY_MILLIS = 86400000L;
|
|
// final long ONE_DAY_MILLIS = 86400000L;
|
|
|
- final long HALF_DAY_MILLIS = 43200000L;
|
|
|
|
|
- Timestamp expireLimit = new Timestamp(System.currentTimeMillis() - HALF_DAY_MILLIS);
|
|
|
|
|
- List<DeploymentPO> deploymentPOList = deploymentMapper.selectAllDeployments();
|
|
|
|
|
- for (DeploymentPO deploymentPO: deploymentPOList) {
|
|
|
|
|
- Timestamp deployedTime = deploymentPO.getDeployedTime();
|
|
|
|
|
- if (deployedTime.before(expireLimit)) {
|
|
|
|
|
- PipelinePO pipelinePO = pipelineMapper.selectById(deploymentPO.getPipelineId());
|
|
|
|
|
- try {
|
|
|
|
|
- deploymentService.delete(pipelinePO.getProjectId(), deploymentPO.getPipelineId());
|
|
|
|
|
- } catch (AccessDeniedException e) {
|
|
|
|
|
- log.error(String.format("Scheduled Deployments Purge Failed for projectId: %s, pipelineId: %s, for %s",
|
|
|
|
|
- pipelinePO.getProjectId(),
|
|
|
|
|
- deploymentPO.getPipelineId(),
|
|
|
|
|
- e.getMessage()));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// final long HALF_DAY_MILLIS = 43200000L;
|
|
|
|
|
+// Timestamp expireLimit = new Timestamp(System.currentTimeMillis() - HALF_DAY_MILLIS);
|
|
|
|
|
+// List<DeploymentPO> deploymentPOList = deploymentMapper.selectAllDeployments();
|
|
|
|
|
+// for (DeploymentPO deploymentPO: deploymentPOList) {
|
|
|
|
|
+// Timestamp deployedTime = deploymentPO.getDeployedTime();
|
|
|
|
|
+// if (deployedTime.before(expireLimit)) {
|
|
|
|
|
+// PipelinePO pipelinePO = pipelineMapper.selectById(deploymentPO.getPipelineId());
|
|
|
|
|
+// try {
|
|
|
|
|
+// deploymentService.delete(pipelinePO.getProjectId(), deploymentPO.getPipelineId());
|
|
|
|
|
+// } catch (AccessDeniedException e) {
|
|
|
|
|
+// log.error(String.format("Scheduled Deployments Purge Failed for projectId: %s, pipelineId: %s, for %s",
|
|
|
|
|
+// pipelinePO.getProjectId(),
|
|
|
|
|
+// deploymentPO.getPipelineId(),
|
|
|
|
|
+// e.getMessage()));
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
|
|
+// }
|
|
|
}
|
|
}
|