From 6a08b51d719bec4ac9da671497277d2f4164d41f Mon Sep 17 00:00:00 2001 From: Paolo Patierno Date: Sun, 1 Mar 2020 09:29:10 +0100 Subject: [PATCH] Removed the need for deploymentName label --- .../scaledobject/scaledobject_controller.go | 23 ++++--------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/pkg/controller/scaledobject/scaledobject_controller.go b/pkg/controller/scaledobject/scaledobject_controller.go index ea2b45a5acf..4d78e78084e 100644 --- a/pkg/controller/scaledobject/scaledobject_controller.go +++ b/pkg/controller/scaledobject/scaledobject_controller.go @@ -280,26 +280,11 @@ func checkDeploymentTypeScaledObject(scaledObject *kedav1alpha1.ScaledObject) (s var errMsg string deploymentName := scaledObject.Spec.ScaleTargetRef.DeploymentName - labelDeploymentName := scaledObject.Labels["deploymentName"] if deploymentName == "" { errMsg = "ScaledObject.spec.scaleTargetRef.deploymentName is missing" - } - if labelDeploymentName == "" { - if errMsg != "" { - errMsg += ", " - } - errMsg += "ScaledObject.metadata.labels.deploymentName is missing" - } - if deploymentName != "" && labelDeploymentName != "" && - labelDeploymentName != deploymentName { - errMsg = errMsg + "ScaledObject.spec.scaleTargetRef.deploymentName and ScaledObject.metadata.labels.deploymentName are not equal" - } - - if errMsg != "" { err = fmt.Errorf(errMsg) } - return deploymentName, err } @@ -357,11 +342,11 @@ func (r *ReconcileScaledObject) newHPAForScaledObject(logger logr.Logger, scaled deploymentName := scaledObject.Spec.ScaleTargetRef.DeploymentName scaledObjectMetricSpecs, err := r.getScaledObjectMetricSpecs(logger, scaledObject, deploymentName) labels := map[string]string{ - "app.kubernetes.io/name": getHpaName(deploymentName), - "app.kubernetes.io/version": version.Version, - "app.kubernetes.io/part-of": scaledObject.GetName(), + "app.kubernetes.io/name": getHpaName(deploymentName), + "app.kubernetes.io/version": version.Version, + "app.kubernetes.io/part-of": scaledObject.GetName(), "app.kubernetes.io/managed-by": "keda-operator", - } + } if err != nil { return nil, err