Add support for custom metrics for HPA (#2423)
* Add support for custom metrics for HPA * Cleanup TargetCPUPercent references from possible places * HPA v2beta has 80% default cpu limit if not set Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -21,8 +21,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/executor/util/hpa"
|
||||
"github.com/fission/fission/pkg/fission-cli/cliwrapper/driver/dummy"
|
||||
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
|
||||
)
|
||||
@@ -71,7 +73,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: DEFAULT_MIN_SCALE,
|
||||
MaxScale: DEFAULT_MIN_SCALE,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -92,7 +93,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: DEFAULT_MIN_SCALE,
|
||||
MaxScale: DEFAULT_MIN_SCALE,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -107,7 +107,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: DEFAULT_MIN_SCALE,
|
||||
MaxScale: DEFAULT_MIN_SCALE,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -134,7 +133,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 3,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -164,7 +162,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 5,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -183,7 +180,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: DEFAULT_MIN_SCALE,
|
||||
MaxScale: 3,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -211,7 +207,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -230,7 +225,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -240,7 +234,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 9,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -257,7 +250,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -267,7 +259,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -286,7 +277,7 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: DEFAULT_MIN_SCALE,
|
||||
MaxScale: DEFAULT_MIN_SCALE,
|
||||
TargetCPUPercent: 50,
|
||||
Metrics: []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(50)},
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -304,7 +295,7 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: 88,
|
||||
Metrics: []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(88)},
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -314,7 +305,7 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: 20,
|
||||
Metrics: []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(20)},
|
||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||
},
|
||||
},
|
||||
@@ -329,10 +320,9 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
existingInvokeStrategy: &fv1.InvokeStrategy{
|
||||
StrategyType: fv1.StrategyTypeExecution,
|
||||
ExecutionStrategy: fv1.ExecutionStrategy{
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
},
|
||||
},
|
||||
expectedResult: &fv1.InvokeStrategy{
|
||||
@@ -342,7 +332,6 @@ func TestGetInvokeStrategy(t *testing.T) {
|
||||
MinScale: 2,
|
||||
MaxScale: 5,
|
||||
SpecializationTimeout: 200,
|
||||
TargetCPUPercent: DEFAULT_TARGET_CPU_PERCENTAGE,
|
||||
},
|
||||
},
|
||||
expectError: false,
|
||||
|
||||
Reference in New Issue
Block a user