diff --git a/apis/keda/v1alpha1/scaledjob_types.go b/apis/keda/v1alpha1/scaledjob_types.go index 068802851fb..946cfe9a248 100644 --- a/apis/keda/v1alpha1/scaledjob_types.go +++ b/apis/keda/v1alpha1/scaledjob_types.go @@ -88,7 +88,7 @@ type ScalingStrategy struct { // +optional PendingPodConditions []string `json:"pendingPodConditions,omitempty"` // +optional - MultipleScalersOption string `json:"multipleScalersOption,omitempty"` + MultipleScalersCalculation string `json:"multipleScalersCalculation,omitempty"` } func init() { diff --git a/config/crd/bases/keda.sh_scaledjobs.yaml b/config/crd/bases/keda.sh_scaledjobs.yaml index 9a7dcb2c2e3..511680bc103 100644 --- a/config/crd/bases/keda.sh_scaledjobs.yaml +++ b/config/crd/bases/keda.sh_scaledjobs.yaml @@ -7362,7 +7362,7 @@ spec: type: integer customScalingRunningJobPercentage: type: string - multipleScalersOption: + multipleScalersCalculation: type: string pendingPodConditions: items: diff --git a/pkg/scaling/scaledjob/scale_metrics.go b/pkg/scaling/scaledjob/scale_metrics.go index c2ba7247eb1..8a975844d28 100644 --- a/pkg/scaling/scaledjob/scale_metrics.go +++ b/pkg/scaling/scaledjob/scale_metrics.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-logr/logr" - kedav1alpha1 "github.com/kedacore/keda/v2/api/v1alpha1" + kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" "github.com/kedacore/keda/v2/pkg/eventreason" "github.com/kedacore/keda/v2/pkg/scalers" "k8s.io/api/autoscaling/v2beta2" @@ -28,7 +28,7 @@ func GetScaleMetrics(ctx context.Context, scalers []scalers.Scaler, scaledJob *k logger := logf.Log.WithName("scalemetrics") scalersMetrics := getScalersMetrics(ctx, scalers, scaledJob, logger, recorder) - switch scaledJob.Spec.ScalingStrategy.MultipleScalersOption { + switch scaledJob.Spec.ScalingStrategy.MultipleScalersCalculation { case "min": for _, metrics := range scalersMetrics { if (queueLength == 0 || metrics.queueLength < queueLength) && metrics.isActive { @@ -71,7 +71,7 @@ func GetScaleMetrics(ctx context.Context, scalers []scalers.Scaler, scaledJob *k } } maxValue = min(scaledJob.MaxReplicaCount(), maxValue) - logger.V(1).WithValues("ScaledJob", scaledJob.Name).Info("Checking if ScaleJob scalers are active", "isActive", isActive, "maxValue", maxValue, "MultipleScalersOption", scaledJob.Spec.ScalingStrategy.MultipleScalersOption) + logger.V(1).WithValues("ScaledJob", scaledJob.Name).Info("Checking if ScaleJob scalers are active", "isActive", isActive, "maxValue", maxValue, "MultipleScalersCalculation", scaledJob.Spec.ScalingStrategy.MultipleScalersCalculation) return isActive, queueLength, maxValue } diff --git a/pkg/scaling/scaledjob/scale_metrics_test.go b/pkg/scaling/scaledjob/scale_metrics_test.go index 32d21d88850..cd4a2f2d417 100644 --- a/pkg/scaling/scaledjob/scale_metrics_test.go +++ b/pkg/scaling/scaledjob/scale_metrics_test.go @@ -7,7 +7,7 @@ import ( "github.com/go-playground/assert/v2" "github.com/golang/mock/gomock" - kedav1alpha1 "github.com/kedacore/keda/v2/api/v1alpha1" + kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" mock_scalers "github.com/kedacore/keda/v2/pkg/mock/mock_scaler" "github.com/kedacore/keda/v2/pkg/scalers" "k8s.io/api/autoscaling/v2beta2" @@ -94,7 +94,7 @@ func TestIsScaledJobActive(t *testing.T) { } for index, scalerTestData := range scalerTestDatam { - scaledJob := createScaledObject(scalerTestData.MaxReplicaCount, scalerTestData.MultipleScalersOption) + scaledJob := createScaledObject(scalerTestData.MaxReplicaCount, scalerTestData.MultipleScalersCalculation) scalers := []scalers.Scaler{ createScaler(ctrl, scalerTestData.Scaler1QueueLength, scalerTestData.Scaler1AverageValue, scalerTestData.Scaler1IsActive), createScaler(ctrl, scalerTestData.Scaler2QueueLength, scalerTestData.Scaler2AverageValue, scalerTestData.Scaler2IsActive), @@ -112,7 +112,7 @@ func TestIsScaledJobActive(t *testing.T) { func newScalerTestData( maxReplicaCount int, - multipleScalersOption string, + multipleScalersCalculation string, scaler1QueueLength, //nolint:golint,unparam scaler1AverageValue int, //nolint:golint,unparam scaler1IsActive bool, //nolint:golint,unparam @@ -129,53 +129,53 @@ func newScalerTestData( resultQueueLength, resultMaxLength int) scalerTestData { return scalerTestData{ - MaxReplicaCount: int32(maxReplicaCount), - MultipleScalersOption: multipleScalersOption, - Scaler1QueueLength: int64(scaler1QueueLength), - Scaler1AverageValue: int32(scaler1AverageValue), - Scaler1IsActive: scaler1IsActive, - Scaler2QueueLength: int64(scaler2QueueLength), - Scaler2AverageValue: int32(scaler2AverageValue), - Scaler2IsActive: scaler2IsActive, - Scaler3QueueLength: int64(scaler3QueueLength), - Scaler3AverageValue: int32(scaler3AverageValue), - Scaler3IsActive: scaler3IsActive, - Scaler4QueueLength: int64(scaler4QueueLength), - Scaler4AverageValue: int32(scaler4AverageValue), - Scaler4IsActive: scaler4IsActive, - ResultIsActive: resultIsActive, - ResultQueueLength: int64(resultQueueLength), - ResultMaxValue: int64(resultMaxLength), + MaxReplicaCount: int32(maxReplicaCount), + MultipleScalersCalculation: multipleScalersCalculation, + Scaler1QueueLength: int64(scaler1QueueLength), + Scaler1AverageValue: int32(scaler1AverageValue), + Scaler1IsActive: scaler1IsActive, + Scaler2QueueLength: int64(scaler2QueueLength), + Scaler2AverageValue: int32(scaler2AverageValue), + Scaler2IsActive: scaler2IsActive, + Scaler3QueueLength: int64(scaler3QueueLength), + Scaler3AverageValue: int32(scaler3AverageValue), + Scaler3IsActive: scaler3IsActive, + Scaler4QueueLength: int64(scaler4QueueLength), + Scaler4AverageValue: int32(scaler4AverageValue), + Scaler4IsActive: scaler4IsActive, + ResultIsActive: resultIsActive, + ResultQueueLength: int64(resultQueueLength), + ResultMaxValue: int64(resultMaxLength), } } type scalerTestData struct { - MaxReplicaCount int32 - MultipleScalersOption string - Scaler1QueueLength int64 - Scaler1AverageValue int32 - Scaler1IsActive bool - Scaler2QueueLength int64 - Scaler2AverageValue int32 - Scaler2IsActive bool - Scaler3QueueLength int64 - Scaler3AverageValue int32 - Scaler3IsActive bool - Scaler4QueueLength int64 - Scaler4AverageValue int32 - Scaler4IsActive bool - ResultIsActive bool - ResultQueueLength int64 - ResultMaxValue int64 + MaxReplicaCount int32 + MultipleScalersCalculation string + Scaler1QueueLength int64 + Scaler1AverageValue int32 + Scaler1IsActive bool + Scaler2QueueLength int64 + Scaler2AverageValue int32 + Scaler2IsActive bool + Scaler3QueueLength int64 + Scaler3AverageValue int32 + Scaler3IsActive bool + Scaler4QueueLength int64 + Scaler4AverageValue int32 + Scaler4IsActive bool + ResultIsActive bool + ResultQueueLength int64 + ResultMaxValue int64 } -func createScaledObject(maxReplicaCount int32, multipleScalersOption string) *kedav1alpha1.ScaledJob { - if multipleScalersOption != "" { +func createScaledObject(maxReplicaCount int32, multipleScalersCalculation string) *kedav1alpha1.ScaledJob { + if multipleScalersCalculation != "" { return &kedav1alpha1.ScaledJob{ Spec: kedav1alpha1.ScaledJobSpec{ MaxReplicaCount: &maxReplicaCount, ScalingStrategy: kedav1alpha1.ScalingStrategy{ - MultipleScalersOption: multipleScalersOption, + MultipleScalersCalculation: multipleScalersCalculation, }, }, }