stratos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject [01/11] git commit: not scaling down if active replicas are less than required replicas
Date Sat, 11 Oct 2014 19:04:46 GMT
Repository: stratos
Updated Branches:
  refs/heads/master a6f4efe6b -> b299559d1


not scaling down if active replicas are less than required replicas


Project: http://git-wip-us.apache.org/repos/asf/stratos/repo
Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bbdc7cf2
Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bbdc7cf2
Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bbdc7cf2

Branch: refs/heads/master
Commit: bbdc7cf258ca0ec996fd2ed13ed34651b53170e6
Parents: f2252b7
Author: R-Rajkumar <rraju1990@gmail.com>
Authored: Sat Oct 11 19:29:28 2014 +0530
Committer: R-Rajkumar <rraju1990@gmail.com>
Committed: Sat Oct 11 19:29:28 2014 +0530

----------------------------------------------------------------------
 .../src/main/conf/container-mincheck.drl        | 15 ++---
 .../src/main/conf/container-scaling.drl         | 62 ++++++++++++--------
 2 files changed, 44 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/stratos/blob/bbdc7cf2/products/stratos/modules/distribution/src/main/conf/container-mincheck.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/container-mincheck.drl b/products/stratos/modules/distribution/src/main/conf/container-mincheck.drl
index 9798852..f87a556 100644
--- a/products/stratos/modules/distribution/src/main/conf/container-mincheck.drl
+++ b/products/stratos/modules/distribution/src/main/conf/container-mincheck.drl
@@ -35,16 +35,16 @@ dialect "mvel"
            nonTerminatedReplicas : Integer() from $kubernetesClusterContext.getNonTerminatedMemberCount()
            isServiceClusterCreated : Boolean() from $kubernetesClusterContext.isServiceClusterCreated()
 	   
-           eval(log.debug("Running minimum rule: [kub-cluster] " +kubernetesClusterId + "
[cluster] " + clusterId))
-           eval(log.debug("[min-check] " + " [cluster] : " + clusterId + " [Replicas] nonTerminated
: " + nonTerminatedReplicas))
-	   eval(log.debug("[min-check] " + " [cluster] : " + clusterId + " [Replicas] minReplicas
: " + minReplicas))
+           eval(log.info("Running minimum rule: [kub-cluster] " + kubernetesClusterId + "
[cluster] " + clusterId))
+           eval(log.info("[min-check] " + " [cluster] : " + clusterId + " [Replicas] nonTerminated
: " + nonTerminatedReplicas))
+	   eval(log.info("[min-check] " + " [cluster] : " + clusterId + " [Replicas] minReplicas
: " + minReplicas))
 	   eval(nonTerminatedReplicas < minReplicas)
        then
            if (isServiceClusterCreated) {
              // we suceeded calling startContainer() once, can't call it again
               log.info("[min-check] Decided to scale-up : [cluster] : " + clusterId);
- 	      log.info("[min-check] " + " [cluster] : " + clusterId + " ; min-rule not satisfied,
expanding cluster to minReplicas : " + minReplicas);
-              $delegator.delegateUpdateContainers($kubernetesClusterContext, minReplicas);
+ 	      log.info("[min-check] " + " [cluster] : " + clusterId + " ; min-rule not satisfied,
scaling up to minReplicas : " + minReplicas);
+              $delegator.delegateScaleUpContainers($kubernetesClusterContext, minReplicas);
 	   } else {
              // we should call startContainer
               log.info("[min-check] Decided to create the cluster : [cluster] : " + clusterId);
@@ -60,12 +60,13 @@ dialect "mvel"
            kubernetesClusterId : String() from $kubernetesClusterContext.getKubernetesClusterID()
            obsoleteReplicas : Integer() from $kubernetesClusterContext.getObsoletedMembers().size()
 
-           eval(log.debug("Running obsolete containers rule [kub-cluster] : " + kubernetesClusterId
+ " [cluster] : " + clusterId))
-           eval(log.debug("[obsolete-check] " + "[cluster] : " + clusterId + " [Replicas]
obsoleteReplicas : " + obsoleteReplicas))
+           eval(log.info("Running obsolete containers rule [kub-cluster] : " + kubernetesClusterId
+ " [cluster] : " + clusterId))
+           eval(log.info("[obsolete-check] " + "[cluster] : " + clusterId + " [Replicas]
obsoleteReplicas : " + obsoleteReplicas))
            eval($kubernetesClusterContext.getObsoletedMembers().keySet().size() > 0)
            memberId : String() from $kubernetesClusterContext.getObsoletedMembers().keySet()
            eval(log.debug("[obsolete-check] [kub-cluster] : " + kubernetesClusterId + " [cluster]
: " + clusterId + " Member id : " + memberId))
         then
+           log.info("[obsolete-check] Terminating the obsolete member with id : " + memberId
+ " in the cluster : " + clusterId);
            $delegator.delegateTerminateContainer($kubernetesClusterContext, memberId);
 end
 

http://git-wip-us.apache.org/repos/asf/stratos/blob/bbdc7cf2/products/stratos/modules/distribution/src/main/conf/container-scaling.drl
----------------------------------------------------------------------
diff --git a/products/stratos/modules/distribution/src/main/conf/container-scaling.drl b/products/stratos/modules/distribution/src/main/conf/container-scaling.drl
index 46d9aeb..1aec0b0 100644
--- a/products/stratos/modules/distribution/src/main/conf/container-scaling.drl
+++ b/products/stratos/modules/distribution/src/main/conf/container-scaling.drl
@@ -31,7 +31,7 @@ global java.lang.Boolean rifReset;
 global java.lang.Boolean mcReset;
 global java.lang.Boolean laReset;
 
-rule "Scaling Rule"
+rule "Containers Scaling Rule"
 dialect "mvel"
 	when
         $kubernetesClusterContext : KubernetesClusterContext ()
@@ -39,8 +39,9 @@ dialect "mvel"
 	minReplicas : Integer() from $kubernetesClusterContext.getMinReplicas()
         maxReplicas : Integer() from $kubernetesClusterContext.getMaxReplicas()
         nonTerminatedReplicas : Integer() from $kubernetesClusterContext.getNonTerminatedMemberCount()
+        activeReplicas : Integer() from $kubernetesClusterContext.getActiveMemberCount()
 
-        eval(log.debug("Running scaling rule [kub-cluster] : " + kubernetesClusterId + "
[cluster] : " + clusterId))
+        eval(log.info("Running scaling rule [kub-cluster] : " + kubernetesClusterId + " [cluster]
: " + clusterId))
 	
 	$loadThresholds : LoadThresholds() from  autoscalePolicy.getLoadThresholds()
 
@@ -72,16 +73,17 @@ dialect "mvel"
         scaleUpForMc : Boolean() from (mcReset && (mcPredictedValue > mcUpperLimit))
         scaleUpForLa : Boolean() from (laReset && (laPredictedValue > laUpperLimit))
 
-	scaleDownForRif : Boolean() from (rifReset && (rifPredictedValue < rifLowerLimit))
-        scaleDownForMc : Boolean() from (mcReset && (mcPredictedValue < mcLowerLimit))

-        scaleDownForLa : Boolean() from (laReset && (laPredictedValue < laLowerLimit))
+	scaleDownForRif : Boolean() from (rifPredictedValue < rifUpperLimit)
+        scaleDownForMc : Boolean() from (mcReset && (mcPredictedValue < mcUpperLimit))

+        scaleDownForLa : Boolean() from (laReset && (laPredictedValue < laUpperLimit))
 
         scaleUp : Boolean() from (scaleUpForRif || scaleUpForMc || scaleUpForLa)
-        scaleDown : Boolean() from (scaleDownForRif && scaleDownForMc &&
 scaleDownForLa)
+        scaleDown : Boolean() from (scaleDownForRif && scaleDownForMc &&
scaleDownForLa)
 
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [Replicas] nonTerminated
: " + nonTerminatedReplicas))
-	eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [Replicas] minReplicas : "
+ minReplicas))
-	eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [Replicas] maxReplicas : "
+ maxReplicas))
+	eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [Replicas] minReplicas : "
+ minReplicas))
+	eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [Replicas] maxReplicas : "
+ maxReplicas))
+	eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [Replicas] nonTerminated :
" + nonTerminatedReplicas))
+	eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [Replicas] activeReplicas :
" + activeReplicas))
 
         eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [RequestInFlight] resetted
? : " + rifReset))
         eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [RequestInFlight] predicted
value : " + rifPredictedValue))
@@ -89,17 +91,17 @@ dialect "mvel"
         eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [RequestInFlight] lower
limit : " + rifLowerLimit))
 
 	eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption] resetted
? : " + mcReset))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption]
predicted value : " + mcPredictedValue))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption]
upper limit : " + mcUpperLimit))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption]
lower limit : " + mcLowerLimit))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption]
predicted value : " + mcPredictedValue))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption]
upper limit : " + mcUpperLimit))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [MemoryConsumption]
lower limit : " + mcLowerLimit))
 
 	eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] resetted ? :
" + laReset))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] predicted
value : " + laPredictedValue))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] upper
limit : " + laUpperLimit))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] lower
limit : " + laLowerLimit))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] predicted
value : " + laPredictedValue))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] upper
limit : " + laUpperLimit))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " [LoadAverage] lower
limit : " + laLowerLimit))
 
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " scale-up action : "
+ scaleUp))
-        eval(log.debug("[scaling] " + " [cluster] : " + clusterId + " scale-down action :
" + scaleDown))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " scale-up action : "
+ scaleUp))
+        eval(log.info("[scaling] " + " [cluster] : " + clusterId + " scale-down action :
" + scaleDown))
 
 	then
         if (scaleUp) {
@@ -139,23 +141,31 @@ dialect "mvel"
             if (requiredReplicas > nonTerminatedReplicas) {
               log.info("[scaling] Decided to scale-up : [cluster] : " + clusterId);
  	      log.info("[scaling-up] " + " [cluster] : " + clusterId + " valid number of replicas
to expand : " + requiredReplicas);
-	      $delegator.delegateUpdateContainers($kubernetesClusterContext, requiredReplicas);
+	      $delegator.delegateScaleUpContainers($kubernetesClusterContext, requiredReplicas);
             }
             //shrink the cluster
             if (requiredReplicas < nonTerminatedReplicas) {
-              log.info("[scaling] Decided to scale-down : [cluster] : " + clusterId);
- 	      log.info("[scaling-down] " + " [cluster] : " + clusterId + " valid number of replicas
to shrink : " + requiredReplicas);
-	      $delegator.delegateUpdateContainers($kubernetesClusterContext, requiredReplicas);
+              if (requiredReplicas < activeReplicas) {
+                log.info("[scaling] Decided to scale-down : [cluster] : " + clusterId);
+ 	        log.info("[scaling-down] " + " [cluster] : " + clusterId + " valid number of replicas
to shrink : " + requiredReplicas);
+	        $delegator.delegateScaleDownContainers($kubernetesClusterContext, requiredReplicas);
+              } else {
+	        log.info("[scaling] " + " [cluster] : " + clusterId + " Even if requiredReplicas
< nonTerminatedReplicas, still requiredReplicas >= activeReplicas ; hence not scaling
down ");
+              }
             }
             if (requiredReplicas == nonTerminatedReplicas) {
- 	      log.info("[scaling] " + " [cluster] : " + clusterId + "non terminated replicas and
predicted replicas are same");
+ 	      log.info("[scaling] " + " [cluster] : " + clusterId + " Non terminated replicas and
predicted replicas are same");
             }
             
         } else if (scaleDown) {
-            log.info("[scaling] Decided to scale-down [cluster] : " + clusterId);
-            log.info("[scaling-down] " + " [cluster] : " + clusterId + " shrink the cluster
to minReplicas : " + minReplicas);
-            //shrink the cluster to minReplicas
-            $delegator.delegateUpdateContainers($kubernetesClusterContext, minReplicas);
+            if (activeReplicas > minReplicas) {
+              log.info("[scaling] Decided to scale-down [cluster] : " + clusterId);
+              log.info("[scaling-down] " + " [cluster] : " + clusterId + " shrink the cluster
to minReplicas : " + minReplicas);
+              //shrink the cluster to minReplicas
+              $delegator.delegateScaleDownContainers($kubernetesClusterContext, minReplicas);
+            } else {
+	      log.info("[scaling] " + " [cluster] : " + clusterId + " Even if all predicted stats
< upperLimit, activeReplicas == minReplicas ; hence not scaling down ");
+            }
         } else {
             log.info("[scaling] No decision made to either scale up or down ... ");
         }


Mime
View raw message