Fix autoscale inconsistence UI

fixed autoscale Cli and Appfile inconsistence
and refactor `vela status` output for autoscale
This commit is contained in:
zzxwill
2020-11-10 20:30:04 +08:00
parent 025ce5d74d
commit da8457fbf0
3 changed files with 19 additions and 19 deletions
+12 -12
View File
@@ -29,7 +29,7 @@ is supported.
Type: webservice
HEALTHY Ready: 1/1
Traits:
- ✅ autoscale: type: cpu minReplicas: 1 maxReplicas: 5 CPUUtilization(target/current): 5%/0% replicas: 0
- ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/0% replicas(min/max/current): 1/5/0
Last Deployment:
Created at: 2020-11-06 16:10:54 +0800 CST
Updated at: 2020-11-06T16:19:04+08:0
@@ -79,7 +79,7 @@ is supported.
Type: webservice
HEALTHY Ready: 1/1
Traits:
- ✅ autoscale: type: cpu minReplicas: 1 maxReplicas: 5 CPUUtilization(target/current): 5%/10% replicas: 2
- ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/10% replicas(min/max/current): 1/5/2
Last Deployment:
Created at: 2020-11-05 20:07:23 +0800 CST
Updated at: 2020-11-05T20:50:42+08:00
@@ -100,7 +100,7 @@ is supported.
Type: webservice
HEALTHY Ready: 1/1
Traits:
- ✅ autoscale: type: cpu minReplicas: 1 maxReplicas: 5 CPUUtilization(target/current): 5%/14% replicas: 4
- ✅ autoscale: type: cpu cpu-utilization(target/current): 5%/14% replicas(min/max/current): 1/5/4
Last Deployment:
Created at: 2020-11-05 20:07:23 +0800 CST
Updated at: 2020-11-05T20:50:42+08:00
@@ -132,8 +132,8 @@ Introduce how to automatically scale workloads by cron in Appfile.
port: 8080
autoscale:
minReplicas: 1
maxReplicas: 4
min: 1
max: 4
cron:
startAt: "14:00"
duration: "2h"
@@ -202,7 +202,7 @@ Introduce how to automatically scale workloads by cron in Appfile.
Type: webservice
HEALTHY Ready: 1/1
Traits:
- ✅ autoscale: type: cron minReplicas: 1 maxReplicas: 4 replicas: 1
- ✅ autoscale: type: cron replicas(min/max/current): 1/4/1
Last Deployment:
Created at: 2020-11-05 17:09:03 +0800 CST
Updated at: 2020-11-05T17:09:02+08:00
@@ -217,19 +217,19 @@ Introduce how to automatically scale workloads by cron in Appfile.
Name: testapp
Namespace: default
Created at: 2020-11-05 17:09:02.426632 +0800 CST
Updated at: 2020-11-05 17:09:02.426632 +0800 CST
Created at: 2020-11-10 10:18:59.498079 +0800 CST
Updated at: 2020-11-10 10:18:59.49808 +0800 CST
Services:
- Name: express-server
Type: webservice
HEALTHY Ready: 1/1
HEALTHY Ready: 2/2
Traits:
- ✅ autoscale: type: cron minReplicas: 1 maxReplicas: 4 replicas: 2
- ✅ autoscale: type: cron replicas(min/max/current): 1/4/2
Last Deployment:
Created at: 2020-11-05 17:09:03 +0800 CST
Updated at: 2020-11-05T17:09:02+08:00
Created at: 2020-11-10 10:18:59 +0800 CST
Updated at: 2020-11-10T10:18:59+08:00
```
Wait after the period ends, the replicas will be one eventually.
+2 -2
View File
@@ -37,8 +37,8 @@ services:
# enabled: true
# autoscale:
# minReplicas: 1
# maxReplicas: 4
# min: 1
# max: 4
# cron:
# startAt: "14:00"
# duration: "2h"
+5 -5
View File
@@ -156,8 +156,7 @@ func (d *AutoscalerChecker) Check(ctx context.Context, ref runtimev1alpha1.Typed
if err := d.c.Get(ctx, client.ObjectKey{Namespace: appConfig.Namespace, Name: hpaName}, &hpa); err != nil {
return StatusChecking, "", err
}
message := fmt.Sprintf("type: %s\tminReplicas: %v\tmaxReplicas: %v\t", scalerType, *hpa.Spec.MinReplicas,
hpa.Spec.MaxReplicas)
message := fmt.Sprintf("type: %-8s", scalerType)
if scalerType == string(autoscalers.CPUType) {
// When attaching trait, and before the scaler trait works, `CurrentCPUUtilizationPercentage` is nil
currentCPUUtilizationPercentage := hpa.Status.CurrentCPUUtilizationPercentage
@@ -165,10 +164,11 @@ func (d *AutoscalerChecker) Check(ctx context.Context, ref runtimev1alpha1.Typed
if currentCPUUtilizationPercentage == nil {
currentCPUUtilizationPercentage = &zeroPercentage
}
message += fmt.Sprintf("CPUUtilization(target/current): %v%%/%v%%\t", *hpa.Spec.TargetCPUUtilizationPercentage,
*currentCPUUtilizationPercentage)
message += fmt.Sprintf("cpu-utilization(target/current): %v%%/%v%%\t",
*hpa.Spec.TargetCPUUtilizationPercentage, *currentCPUUtilizationPercentage)
}
message += fmt.Sprintf("replicas: %v", hpa.Status.CurrentReplicas)
message += fmt.Sprintf("replicas(min/max/current): %v/%v/%v", *hpa.Spec.MinReplicas, hpa.Spec.MaxReplicas,
hpa.Status.CurrentReplicas)
return StatusDone, message, nil
}