From 5515a5c586c20fa5c73ec9cf7a198622434bf6bd Mon Sep 17 00:00:00 2001 From: lasinducharith Date: Mon, 17 Aug 2015 08:27:14 +0530 Subject: [PATCH] STRATOS-1499 - setting auto increment cluster-id as kubernetes serviceLabel --- .../domain/kubernetes/KubernetesClusterContext.java | 6 ++++++ .../cloud/controller/iaases/kubernetes/KubernetesIaas.java | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/kubernetes/KubernetesClusterContext.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/kubernetes/KubernetesClusterContext.java index 38c49a039e..8e1bdd9756 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/kubernetes/KubernetesClusterContext.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/domain/kubernetes/KubernetesClusterContext.java @@ -48,6 +48,7 @@ public class KubernetesClusterContext implements Serializable { private transient KubernetesApiClient kubApi; private AtomicLong serviceSeqNo; private AtomicLong podSeqNo; + private AtomicLong clusterSeqNo; public KubernetesClusterContext(String id, String masterIp, String masterPort, int lowerPort, int upperPort) { servicePorts = new ArrayList(); @@ -61,6 +62,7 @@ public KubernetesClusterContext(String id, String masterIp, String masterPort, i this.setKubApi(new KubernetesApiClient(getEndpoint(masterIp, masterPort))); this.serviceSeqNo = new AtomicLong(); this.podSeqNo = new AtomicLong(); + this.clusterSeqNo = new AtomicLong(); } @@ -147,6 +149,10 @@ public AtomicLong getPodSeqNo() { return podSeqNo; } + public AtomicLong getClusterSeqNo(){ + return clusterSeqNo; + } + @Override public int hashCode() { final int prime = 31; diff --git a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java index 22f3c9bbf2..fe1d49f484 100644 --- a/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java +++ b/components/org.apache.stratos.cloud.controller/src/main/java/org/apache/stratos/cloud/controller/iaases/kubernetes/KubernetesIaas.java @@ -510,7 +510,8 @@ private void createKubernetesServices(KubernetesApiClient kubernetesApi, Cluster // Find next service sequence no long serviceSeqNo = kubernetesClusterContext.getServiceSeqNo().incrementAndGet(); String serviceId = KubernetesIaasUtil.fixSpecialCharacters("service" + "-" + (serviceSeqNo)); - String serviceLabel = KubernetesIaasUtil.fixSpecialCharacters(clusterId); + long clusterSeqNo = kubernetesClusterContext.getClusterSeqNo().incrementAndGet(); + String serviceLabel = KubernetesIaasUtil.fixSpecialCharacters("cluster" + "-" + (clusterSeqNo)); if (log.isInfoEnabled()) { log.info(String.format("Creating kubernetes service: [cluster] %s [service] %s " +