Java Code Examples for org.joda.time.DateTime.minusWeeks()

The following are Jave code examples for showing how to use minusWeeks() of the org.joda.time.DateTime class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: kubekleaner   File: CleanupServiceImpl.java   Source Code and License Vote up 6 votes
public void removeResources(PodResource pod, DeploymentResource deployment, String cluster, String namespace,
							String name) {
	if (pod.getStatus().getContainerStatuses() != null && pod.getStatus().getContainerStatuses()[0]
			.getState().getWaiting() != null && deployment.getMetadata().getLabels()
			.get(crashLoopDetectionTimeLiteral) != null) {
		DateTime currentTime = new DateTime();
		DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH.mm.ss'Z'");
		DateTime timeCutoff = currentTime.minusWeeks(kubernetesConfig.getNumWeeks());
		DateTime crashLoopTime = format.parseDateTime(deployment.getMetadata().getLabels()
				.get(crashLoopDetectionTimeLiteral)).toDateTime();
		if (timeCutoff.isAfter(crashLoopTime)) {
			deploymentResourceService.deleteDeploymentResource(cluster, namespace, name);
			replicasetResourceService.deleteReplicasetResource(cluster, namespace, name);
			podResourceService.deletePodResource(cluster, namespace, name);
			serviceResourceService.deleteService(cluster, namespace, name);
			ingressResourceService.deleteIngressResource(cluster, namespace, name);
			autoscalerResourceService.deleteAutoscaler(cluster, namespace, name);
			hipchatService.notifyDelete(cluster, namespace, name);
		}
	}
}