* Update the Kubernetes autoscaling API to v2 (#2722) - k8s.io/api/autoscaling/v2 * generate all files * fix missing v2beta ref --------- Signed-off-by: Lunik <lunik@tiwabbit.fr>
This commit is contained in:
@@ -112,10 +112,11 @@ spec:
|
|||||||
- value
|
- value
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
x-kubernetes-list-type: atomic
|
||||||
selectPolicy:
|
selectPolicy:
|
||||||
description: selectPolicy is used to specify which
|
description: selectPolicy is used to specify which
|
||||||
policy should be used. If not set, the default value
|
policy should be used. If not set, the default value
|
||||||
MaxPolicySelect is used.
|
Max is used.
|
||||||
type: string
|
type: string
|
||||||
stabilizationWindowSeconds:
|
stabilizationWindowSeconds:
|
||||||
description: 'stabilizationWindowSeconds is the number
|
description: 'stabilizationWindowSeconds is the number
|
||||||
@@ -168,10 +169,11 @@ spec:
|
|||||||
- value
|
- value
|
||||||
type: object
|
type: object
|
||||||
type: array
|
type: array
|
||||||
|
x-kubernetes-list-type: atomic
|
||||||
selectPolicy:
|
selectPolicy:
|
||||||
description: selectPolicy is used to specify which
|
description: selectPolicy is used to specify which
|
||||||
policy should be used. If not set, the default value
|
policy should be used. If not set, the default value
|
||||||
MaxPolicySelect is used.
|
Max is used.
|
||||||
type: string
|
type: string
|
||||||
stabilizationWindowSeconds:
|
stabilizationWindowSeconds:
|
||||||
description: 'stabilizationWindowSeconds is the number
|
description: 'stabilizationWindowSeconds is the number
|
||||||
@@ -198,7 +200,7 @@ spec:
|
|||||||
should be set at once).
|
should be set at once).
|
||||||
properties:
|
properties:
|
||||||
containerResource:
|
containerResource:
|
||||||
description: container resource refers to a resource
|
description: containerResource refers to a resource
|
||||||
metric (such as those specified in requests and limits)
|
metric (such as those specified in requests and limits)
|
||||||
known to Kubernetes describing a single container
|
known to Kubernetes describing a single container
|
||||||
in each pod of the current scale target (e.g. CPU
|
in each pod of the current scale target (e.g. CPU
|
||||||
@@ -381,9 +383,8 @@ spec:
|
|||||||
on an Ingress object).
|
on an Ingress object).
|
||||||
properties:
|
properties:
|
||||||
describedObject:
|
describedObject:
|
||||||
description: CrossVersionObjectReference contains
|
description: describedObject specifies the descriptions
|
||||||
enough information to let you identify the referred
|
of a object,such as kind,name apiVersion
|
||||||
resource.
|
|
||||||
properties:
|
properties:
|
||||||
apiVersion:
|
apiVersion:
|
||||||
description: apiVersion is the API version of
|
description: apiVersion is the API version of
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
asv2 "k8s.io/api/autoscaling/v2"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
@@ -475,12 +475,12 @@ type (
|
|||||||
// created for the function.
|
// created for the function.
|
||||||
// Applicable for executor type newdeploy and container.
|
// Applicable for executor type newdeploy and container.
|
||||||
// +optional
|
// +optional
|
||||||
Metrics []asv2beta2.MetricSpec `json:"hpaMetrics,omitempty"`
|
Metrics []asv2.MetricSpec `json:"hpaMetrics,omitempty"`
|
||||||
|
|
||||||
// hpaBehavior is the behavior of HPA when scaling in up/down direction.
|
// hpaBehavior is the behavior of HPA when scaling in up/down direction.
|
||||||
// Applicable for executor type newdeploy and container.
|
// Applicable for executor type newdeploy and container.
|
||||||
// +optional
|
// +optional
|
||||||
Behavior *asv2beta2.HorizontalPodAutoscalerBehavior `json:"hpaBehavior,omitempty"`
|
Behavior *asv2.HorizontalPodAutoscalerBehavior `json:"hpaBehavior,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// FunctionReferenceType refers to type of Function
|
// FunctionReferenceType refers to type of Function
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ limitations under the License.
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"k8s.io/api/autoscaling/v2beta2"
|
"k8s.io/api/autoscaling/v2"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
)
|
)
|
||||||
@@ -302,14 +302,14 @@ func (in *ExecutionStrategy) DeepCopyInto(out *ExecutionStrategy) {
|
|||||||
*out = *in
|
*out = *in
|
||||||
if in.Metrics != nil {
|
if in.Metrics != nil {
|
||||||
in, out := &in.Metrics, &out.Metrics
|
in, out := &in.Metrics, &out.Metrics
|
||||||
*out = make([]v2beta2.MetricSpec, len(*in))
|
*out = make([]v2.MetricSpec, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if in.Behavior != nil {
|
if in.Behavior != nil {
|
||||||
in, out := &in.Behavior, &out.Behavior
|
in, out := &in.Behavior, &out.Behavior
|
||||||
*out = new(v2beta2.HorizontalPodAutoscalerBehavior)
|
*out = new(v2.HorizontalPodAutoscalerBehavior)
|
||||||
(*in).DeepCopyInto(*out)
|
(*in).DeepCopyInto(*out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ func CleanupKubeObject(ctx context.Context, logger *zap.Logger, kubeClient kuber
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "horizontalpodautoscaler":
|
case "horizontalpodautoscaler":
|
||||||
err := kubeClient.AutoscalingV2beta2().HorizontalPodAutoscalers(kubeobj.Namespace).Delete(ctx, kubeobj.Name, metav1.DeleteOptions{})
|
err := kubeClient.AutoscalingV2().HorizontalPodAutoscalers(kubeobj.Namespace).Delete(ctx, kubeobj.Name, metav1.DeleteOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error cleaning up horizontalpodautoscaler", zap.Error(err), zap.String("horizontalpodautoscaler", kubeobj.Name))
|
logger.Error("error cleaning up horizontalpodautoscaler", zap.Error(err), zap.String("horizontalpodautoscaler", kubeobj.Name))
|
||||||
}
|
}
|
||||||
@@ -180,7 +180,7 @@ func CleanupServices(ctx context.Context, logger *zap.Logger, client kubernetes.
|
|||||||
// CleanupHpa deletes horizontal pod autoscaler(s) for a given instanceID
|
// CleanupHpa deletes horizontal pod autoscaler(s) for a given instanceID
|
||||||
func CleanupHpa(ctx context.Context, logger *zap.Logger, client kubernetes.Interface, instanceID string, listOps metav1.ListOptions) error {
|
func CleanupHpa(ctx context.Context, logger *zap.Logger, client kubernetes.Interface, instanceID string, listOps metav1.ListOptions) error {
|
||||||
cleanupHpa := func(namespace string) error {
|
cleanupHpa := func(namespace string) error {
|
||||||
hpaList, err := client.AutoscalingV2beta2().HorizontalPodAutoscalers(namespace).List(ctx, listOps)
|
hpaList, err := client.AutoscalingV2().HorizontalPodAutoscalers(namespace).List(ctx, listOps)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -193,7 +193,7 @@ func CleanupHpa(ctx context.Context, logger *zap.Logger, client kubernetes.Inter
|
|||||||
}
|
}
|
||||||
if ok && id != instanceID {
|
if ok && id != instanceID {
|
||||||
logger.Info("cleaning up HPA", zap.String("hpa", hpa.ObjectMeta.Name))
|
logger.Info("cleaning up HPA", zap.String("hpa", hpa.ObjectMeta.Name))
|
||||||
err := client.AutoscalingV2beta2().HorizontalPodAutoscalers(hpa.ObjectMeta.Namespace).Delete(ctx, hpa.ObjectMeta.Name, metav1.DeleteOptions{})
|
err := client.AutoscalingV2().HorizontalPodAutoscalers(hpa.ObjectMeta.Namespace).Delete(ctx, hpa.ObjectMeta.Name, metav1.DeleteOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("error cleaning up HPA",
|
logger.Error("error cleaning up HPA",
|
||||||
zap.Error(err),
|
zap.Error(err),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
asv2 "k8s.io/api/autoscaling/v2"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
k8s_err "k8s.io/apimachinery/pkg/api/errors"
|
k8s_err "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -51,21 +51,21 @@ func NewHpaOperations(logger *zap.Logger, kubernetesClient kubernetes.Interface,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConvertTargetCPUToCustomMetric(targetCPUVal int32) asv2beta2.MetricSpec {
|
func ConvertTargetCPUToCustomMetric(targetCPUVal int32) asv2.MetricSpec {
|
||||||
return asv2beta2.MetricSpec{
|
return asv2.MetricSpec{
|
||||||
Type: asv2beta2.ResourceMetricSourceType,
|
Type: asv2.ResourceMetricSourceType,
|
||||||
Resource: &asv2beta2.ResourceMetricSource{
|
Resource: &asv2.ResourceMetricSource{
|
||||||
Name: corev1.ResourceCPU,
|
Name: corev1.ResourceCPU,
|
||||||
Target: asv2beta2.MetricTarget{
|
Target: asv2.MetricTarget{
|
||||||
Type: asv2beta2.UtilizationMetricType,
|
Type: asv2.UtilizationMetricType,
|
||||||
AverageUtilization: &targetCPUVal,
|
AverageUtilization: &targetCPUVal,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getScaleTargetRef(deployment *appsv1.Deployment) asv2beta2.CrossVersionObjectReference {
|
func getScaleTargetRef(deployment *appsv1.Deployment) asv2.CrossVersionObjectReference {
|
||||||
return asv2beta2.CrossVersionObjectReference{
|
return asv2.CrossVersionObjectReference{
|
||||||
APIVersion: DeploymentVersion,
|
APIVersion: DeploymentVersion,
|
||||||
Kind: DeploymentKind,
|
Kind: DeploymentKind,
|
||||||
Name: deployment.ObjectMeta.Name,
|
Name: deployment.ObjectMeta.Name,
|
||||||
@@ -73,7 +73,7 @@ func getScaleTargetRef(deployment *appsv1.Deployment) asv2beta2.CrossVersionObje
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string, execStrategy *fv1.ExecutionStrategy,
|
func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string, execStrategy *fv1.ExecutionStrategy,
|
||||||
depl *appsv1.Deployment, deployLabels map[string]string, deployAnnotations map[string]string) (*asv2beta2.HorizontalPodAutoscaler, error) {
|
depl *appsv1.Deployment, deployLabels map[string]string, deployAnnotations map[string]string) (*asv2.HorizontalPodAutoscaler, error) {
|
||||||
|
|
||||||
if depl == nil {
|
if depl == nil {
|
||||||
return nil, errors.New("failed to create HPA, found empty deployment")
|
return nil, errors.New("failed to create HPA, found empty deployment")
|
||||||
@@ -89,7 +89,7 @@ func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string,
|
|||||||
maxRepl = minRepl
|
maxRepl = minRepl
|
||||||
}
|
}
|
||||||
targetCPU := int32(execStrategy.TargetCPUPercent) // nolint: staticcheck
|
targetCPU := int32(execStrategy.TargetCPUPercent) // nolint: staticcheck
|
||||||
var hpaMetrics []asv2beta2.MetricSpec
|
var hpaMetrics []asv2.MetricSpec
|
||||||
if targetCPU > 0 && targetCPU < 100 {
|
if targetCPU > 0 && targetCPU < 100 {
|
||||||
hpaMetrics = append(hpaMetrics, ConvertTargetCPUToCustomMetric(targetCPU))
|
hpaMetrics = append(hpaMetrics, ConvertTargetCPUToCustomMetric(targetCPU))
|
||||||
}
|
}
|
||||||
@@ -98,13 +98,13 @@ func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string,
|
|||||||
hpaMetrics = append(hpaMetrics, execStrategy.Metrics...)
|
hpaMetrics = append(hpaMetrics, execStrategy.Metrics...)
|
||||||
}
|
}
|
||||||
|
|
||||||
hpa := &asv2beta2.HorizontalPodAutoscaler{
|
hpa := &asv2.HorizontalPodAutoscaler{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: hpaName,
|
Name: hpaName,
|
||||||
Labels: deployLabels,
|
Labels: deployLabels,
|
||||||
Annotations: deployAnnotations,
|
Annotations: deployAnnotations,
|
||||||
},
|
},
|
||||||
Spec: asv2beta2.HorizontalPodAutoscalerSpec{
|
Spec: asv2.HorizontalPodAutoscalerSpec{
|
||||||
ScaleTargetRef: getScaleTargetRef(depl),
|
ScaleTargetRef: getScaleTargetRef(depl),
|
||||||
MinReplicas: &minRepl,
|
MinReplicas: &minRepl,
|
||||||
MaxReplicas: maxRepl,
|
MaxReplicas: maxRepl,
|
||||||
@@ -120,7 +120,7 @@ func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string,
|
|||||||
existingHpa.Annotations = hpa.Annotations
|
existingHpa.Annotations = hpa.Annotations
|
||||||
existingHpa.Labels = hpa.Labels
|
existingHpa.Labels = hpa.Labels
|
||||||
existingHpa.Spec = hpa.Spec
|
existingHpa.Spec = hpa.Spec
|
||||||
existingHpa, err = hpaops.kubernetesClient.AutoscalingV2beta2().HorizontalPodAutoscalers(depl.ObjectMeta.Namespace).Update(ctx, existingHpa, metav1.UpdateOptions{})
|
existingHpa, err = hpaops.kubernetesClient.AutoscalingV2().HorizontalPodAutoscalers(depl.ObjectMeta.Namespace).Update(ctx, existingHpa, metav1.UpdateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("error adopting HPA", zap.Error(err),
|
logger.Warn("error adopting HPA", zap.Error(err),
|
||||||
zap.String("HPA", hpaName), zap.String("ns", depl.ObjectMeta.Namespace))
|
zap.String("HPA", hpaName), zap.String("ns", depl.ObjectMeta.Namespace))
|
||||||
@@ -129,10 +129,10 @@ func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string,
|
|||||||
}
|
}
|
||||||
return existingHpa, err
|
return existingHpa, err
|
||||||
} else if k8s_err.IsNotFound(err) {
|
} else if k8s_err.IsNotFound(err) {
|
||||||
cHpa, err := hpaops.kubernetesClient.AutoscalingV2beta2().HorizontalPodAutoscalers(depl.ObjectMeta.Namespace).Create(ctx, hpa, metav1.CreateOptions{})
|
cHpa, err := hpaops.kubernetesClient.AutoscalingV2().HorizontalPodAutoscalers(depl.ObjectMeta.Namespace).Create(ctx, hpa, metav1.CreateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if k8s_err.IsAlreadyExists(err) {
|
if k8s_err.IsAlreadyExists(err) {
|
||||||
cHpa, err = hpaops.kubernetesClient.AutoscalingV2beta2().HorizontalPodAutoscalers(depl.ObjectMeta.Namespace).Get(ctx, hpaName, metav1.GetOptions{})
|
cHpa, err = hpaops.kubernetesClient.AutoscalingV2().HorizontalPodAutoscalers(depl.ObjectMeta.Namespace).Get(ctx, hpaName, metav1.GetOptions{})
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -144,15 +144,15 @@ func (hpaops *HpaOperations) CreateOrGetHpa(ctx context.Context, hpaName string,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hpaops *HpaOperations) GetHpa(ctx context.Context, ns, name string) (*asv2beta2.HorizontalPodAutoscaler, error) {
|
func (hpaops *HpaOperations) GetHpa(ctx context.Context, ns, name string) (*asv2.HorizontalPodAutoscaler, error) {
|
||||||
return hpaops.kubernetesClient.AutoscalingV2beta2().HorizontalPodAutoscalers(ns).Get(ctx, name, metav1.GetOptions{})
|
return hpaops.kubernetesClient.AutoscalingV2().HorizontalPodAutoscalers(ns).Get(ctx, name, metav1.GetOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hpaops *HpaOperations) UpdateHpa(ctx context.Context, hpa *asv2beta2.HorizontalPodAutoscaler) error {
|
func (hpaops *HpaOperations) UpdateHpa(ctx context.Context, hpa *asv2.HorizontalPodAutoscaler) error {
|
||||||
_, err := hpaops.kubernetesClient.AutoscalingV2beta2().HorizontalPodAutoscalers(hpa.ObjectMeta.Namespace).Update(ctx, hpa, metav1.UpdateOptions{})
|
_, err := hpaops.kubernetesClient.AutoscalingV2().HorizontalPodAutoscalers(hpa.ObjectMeta.Namespace).Update(ctx, hpa, metav1.UpdateOptions{})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hpaops *HpaOperations) DeleteHpa(ctx context.Context, ns string, name string) error {
|
func (hpaops *HpaOperations) DeleteHpa(ctx context.Context, ns string, name string) error {
|
||||||
return hpaops.kubernetesClient.AutoscalingV2beta2().HorizontalPodAutoscalers(ns).Delete(ctx, name, metav1.DeleteOptions{})
|
return hpaops.kubernetesClient.AutoscalingV2().HorizontalPodAutoscalers(ns).Delete(ctx, name, metav1.DeleteOptions{})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/dchest/uniuri"
|
"github.com/dchest/uniuri"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
asv2 "k8s.io/api/autoscaling/v2"
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/kubernetes/fake"
|
"k8s.io/client-go/kubernetes/fake"
|
||||||
@@ -33,13 +33,13 @@ import (
|
|||||||
|
|
||||||
func TestConvertTargetCPUToCustomMetric(t *testing.T) {
|
func TestConvertTargetCPUToCustomMetric(t *testing.T) {
|
||||||
metricSpec := ConvertTargetCPUToCustomMetric(50)
|
metricSpec := ConvertTargetCPUToCustomMetric(50)
|
||||||
if metricSpec.Type != asv2beta2.ResourceMetricSourceType {
|
if metricSpec.Type != asv2.ResourceMetricSourceType {
|
||||||
t.Errorf("Expected metric type to be Resource, got %v", metricSpec.Type)
|
t.Errorf("Expected metric type to be Resource, got %v", metricSpec.Type)
|
||||||
}
|
}
|
||||||
if metricSpec.Resource.Name != corev1.ResourceCPU {
|
if metricSpec.Resource.Name != corev1.ResourceCPU {
|
||||||
t.Errorf("Expected metric name to be cpu, got %v", metricSpec.Resource.Name)
|
t.Errorf("Expected metric name to be cpu, got %v", metricSpec.Resource.Name)
|
||||||
}
|
}
|
||||||
if metricSpec.Resource.Target.Type != asv2beta2.UtilizationMetricType {
|
if metricSpec.Resource.Target.Type != asv2.UtilizationMetricType {
|
||||||
t.Errorf("Expected metric target type to be Utilization, got %v", metricSpec.Resource.Target.Type)
|
t.Errorf("Expected metric target type to be Utilization, got %v", metricSpec.Resource.Target.Type)
|
||||||
}
|
}
|
||||||
if metricSpec.Resource.Target.AverageUtilization == nil {
|
if metricSpec.Resource.Target.AverageUtilization == nil {
|
||||||
@@ -92,13 +92,13 @@ func TestHpaOps(t *testing.T) {
|
|||||||
if hpa.Spec.MaxReplicas != 5 {
|
if hpa.Spec.MaxReplicas != 5 {
|
||||||
t.Errorf("Expected max replicas to be 5, got %v", hpa.Spec.MaxReplicas)
|
t.Errorf("Expected max replicas to be 5, got %v", hpa.Spec.MaxReplicas)
|
||||||
}
|
}
|
||||||
if hpa.Spec.Metrics[0].Type != asv2beta2.ResourceMetricSourceType {
|
if hpa.Spec.Metrics[0].Type != asv2.ResourceMetricSourceType {
|
||||||
t.Errorf("Expected metric type to be Resource, got %v", hpa.Spec.Metrics[0].Type)
|
t.Errorf("Expected metric type to be Resource, got %v", hpa.Spec.Metrics[0].Type)
|
||||||
}
|
}
|
||||||
if hpa.Spec.Metrics[0].Resource.Name != corev1.ResourceCPU {
|
if hpa.Spec.Metrics[0].Resource.Name != corev1.ResourceCPU {
|
||||||
t.Errorf("Expected metric name to be cpu, got %v", hpa.Spec.Metrics[0].Resource.Name)
|
t.Errorf("Expected metric name to be cpu, got %v", hpa.Spec.Metrics[0].Resource.Name)
|
||||||
}
|
}
|
||||||
if hpa.Spec.Metrics[0].Resource.Target.Type != asv2beta2.UtilizationMetricType {
|
if hpa.Spec.Metrics[0].Resource.Target.Type != asv2.UtilizationMetricType {
|
||||||
t.Errorf("Expected metric target type to be Utilization, got %v", hpa.Spec.Metrics[0].Resource.Target.Type)
|
t.Errorf("Expected metric target type to be Utilization, got %v", hpa.Spec.Metrics[0].Resource.Target.Type)
|
||||||
}
|
}
|
||||||
if hpa.Spec.Metrics[0].Resource.Target.AverageUtilization == nil {
|
if hpa.Spec.Metrics[0].Resource.Target.AverageUtilization == nil {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
uuid "github.com/satori/go.uuid"
|
uuid "github.com/satori/go.uuid"
|
||||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
asv2 "k8s.io/api/autoscaling/v2"
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@@ -527,7 +527,7 @@ func getExecutionStrategy(fnExecutor fv1.ExecutorType, input cli.Input) (strateg
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
strategy.Metrics = []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(int32(targetCPU))}
|
strategy.Metrics = []asv2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(int32(targetCPU))}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +620,7 @@ func updateExecutionStrategy(input cli.Input, existingExecutionStrategy *fv1.Exe
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
strategy.Metrics = []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(int32(targetCPU))}
|
strategy.Metrics = []asv2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(int32(targetCPU))}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
asv2 "k8s.io/api/autoscaling/v2"
|
||||||
|
|
||||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||||
"github.com/fission/fission/pkg/executor/util/hpa"
|
"github.com/fission/fission/pkg/executor/util/hpa"
|
||||||
@@ -277,7 +277,7 @@ func TestGetInvokeStrategy(t *testing.T) {
|
|||||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||||
MinScale: DEFAULT_MIN_SCALE,
|
MinScale: DEFAULT_MIN_SCALE,
|
||||||
MaxScale: DEFAULT_MIN_SCALE,
|
MaxScale: DEFAULT_MIN_SCALE,
|
||||||
Metrics: []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(50)},
|
Metrics: []asv2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(50)},
|
||||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -295,7 +295,7 @@ func TestGetInvokeStrategy(t *testing.T) {
|
|||||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||||
MinScale: 2,
|
MinScale: 2,
|
||||||
MaxScale: 5,
|
MaxScale: 5,
|
||||||
Metrics: []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(88)},
|
Metrics: []asv2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(88)},
|
||||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -305,7 +305,7 @@ func TestGetInvokeStrategy(t *testing.T) {
|
|||||||
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
ExecutorType: fv1.ExecutorTypeNewdeploy,
|
||||||
MinScale: 2,
|
MinScale: 2,
|
||||||
MaxScale: 5,
|
MaxScale: 5,
|
||||||
Metrics: []asv2beta2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(20)},
|
Metrics: []asv2.MetricSpec{hpa.ConvertTargetCPUToCustomMetric(20)},
|
||||||
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
SpecializationTimeout: fv1.DefaultSpecializationTimeOut,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ func (res KubernetesObjectDumper) Dump(ctx context.Context, dumpDir string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case KubernetesHPA:
|
case KubernetesHPA:
|
||||||
objs, err := res.client.AutoscalingV2beta2().HorizontalPodAutoscalers(metav1.NamespaceAll).List(ctx, metav1.ListOptions{LabelSelector: res.selector})
|
objs, err := res.client.AutoscalingV2().HorizontalPodAutoscalers(metav1.NamespaceAll).List(ctx, metav1.ListOptions{LabelSelector: res.selector})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
console.Error(fmt.Sprintf("Error getting %v list with selector %v: %v", res.objType, res.selector, err))
|
console.Error(fmt.Sprintf("Error getting %v list with selector %v: %v", res.objType, res.selector, err))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"go.opentelemetry.io/otel/attribute"
|
"go.opentelemetry.io/otel/attribute"
|
||||||
"go.opentelemetry.io/otel/trace"
|
"go.opentelemetry.io/otel/trace"
|
||||||
appsv1 "k8s.io/api/apps/v1"
|
appsv1 "k8s.io/api/apps/v1"
|
||||||
asv2beta2 "k8s.io/api/autoscaling/v2beta2"
|
asv2 "k8s.io/api/autoscaling/v2"
|
||||||
|
|
||||||
apiv1 "k8s.io/api/core/v1"
|
apiv1 "k8s.io/api/core/v1"
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ func GetAttributesForDeployment(deployment *appsv1.Deployment) []attribute.KeyVa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAttributesForHPA(hpa *asv2beta2.HorizontalPodAutoscaler) []attribute.KeyValue {
|
func GetAttributesForHPA(hpa *asv2.HorizontalPodAutoscaler) []attribute.KeyValue {
|
||||||
if hpa == nil {
|
if hpa == nil {
|
||||||
return []attribute.KeyValue{}
|
return []attribute.KeyValue{}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user