You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by ra...@apache.org on 2014/09/19 08:18:26 UTC
[2/3] git commit: retrying if container creation failed
retrying if container creation failed
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/becdbf20
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/becdbf20
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/becdbf20
Branch: refs/heads/docker-integration
Commit: becdbf2015e79f7b667c1cd16591e705bd116d4a
Parents: 0fc8b90
Author: R-Rajkumar <rr...@gmail.com>
Authored: Wed Sep 17 10:59:38 2014 +0530
Committer: R-Rajkumar <rr...@gmail.com>
Committed: Wed Sep 17 10:59:38 2014 +0530
----------------------------------------------------------------------
.../monitor/KubernetesClusterMonitor.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/stratos/blob/becdbf20/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java
----------------------------------------------------------------------
diff --git a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java
index dc355d5..a534bed 100644
--- a/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java
+++ b/components/org.apache.stratos.autoscaler/src/main/java/org/apache/stratos/autoscaler/monitor/KubernetesClusterMonitor.java
@@ -28,6 +28,9 @@ public class KubernetesClusterMonitor implements Runnable{
private String lbReferenceType;
private boolean hasPrimary;
private int numberOfReplicasInServiceCluster = 0;
+ // is container created successfully?
+ boolean success = false;
+ int retryInterval = 60000;
public KubernetesClusterMonitor(KubernetesClusterContext kubernetesClusterCtxt, String serviceClusterID, String serviceId,
AutoscalePolicy autoscalePolicy) {
@@ -92,17 +95,20 @@ public class KubernetesClusterMonitor implements Runnable{
if (this.numberOfReplicasInServiceCluster < minReplicas) {
- int numOfAdditionalReplicas = minReplicas - this.numberOfReplicasInServiceCluster;
-
- for (int i = 0; i < numOfAdditionalReplicas; i++) {
+ while (success) {
try {
CloudControllerClient.getInstance().createContainer(kubernetesClusterId, clusterId);
- this.numberOfReplicasInServiceCluster++;
+ success = true;
+ numberOfReplicasInServiceCluster = minReplicas;
} catch (Throwable e) {
- String message = "Cannot create a container";
- log.error(message, e);
- throw new RuntimeException(message, e);
+ String message = "Cannot create a container, will retry in "+(retryInterval/1000)+"s";
+ log.debug(message, e);
}
+
+ try {
+ Thread.sleep(retryInterval);
+ } catch (InterruptedException e1) {
+ }
}
}
} finally {