From c402a0cf9e5160ca7183214aa1d05fb875f7212f Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Mon, 30 Mar 2020 12:07:55 +0200 Subject: [PATCH] HPA: label can have max 63 chars Signed-off-by: Zbynek Roubalik --- pkg/controller/scaledobject/scaledobject_controller.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/controller/scaledobject/scaledobject_controller.go b/pkg/controller/scaledobject/scaledobject_controller.go index 44489c086c3..a220b69be94 100644 --- a/pkg/controller/scaledobject/scaledobject_controller.go +++ b/pkg/controller/scaledobject/scaledobject_controller.go @@ -353,8 +353,16 @@ func (r *ReconcileScaledObject) scaledObjectGenerationChanged(logger logr.Logger func (r *ReconcileScaledObject) newHPAForScaledObject(logger logr.Logger, scaledObject *kedav1alpha1.ScaledObject) (*autoscalingv2beta1.HorizontalPodAutoscaler, error) { deploymentName := scaledObject.Spec.ScaleTargetRef.DeploymentName scaledObjectMetricSpecs, err := r.getScaledObjectMetricSpecs(logger, scaledObject, deploymentName) + + // label can have max 63 chars + labelName := "" + if len(getHpaName(deploymentName)) > 63 { + labelName = getHpaName(deploymentName)[:63] + } else { + labelName = getHpaName(deploymentName) + } labels := map[string]string{ - "app.kubernetes.io/name": getHpaName(deploymentName), + "app.kubernetes.io/name": labelName, "app.kubernetes.io/version": version.Version, "app.kubernetes.io/part-of": scaledObject.GetName(), "app.kubernetes.io/managed-by": "keda-operator",