Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to create HPA if ScaledObject name is longer than 63 characters #6370

Open
s-shirayama opened this issue Nov 28, 2024 · 0 comments · May be fixed by #6382
Open

Fail to create HPA if ScaledObject name is longer than 63 characters #6370

s-shirayama opened this issue Nov 28, 2024 · 0 comments · May be fixed by #6382
Labels
bug Something isn't working

Comments

@s-shirayama
Copy link

Report

When a ScaledObject is created with a long name of more than 63 characters, KEDA fails to create HPA because of the limitation of the label length in the k8s resource.

Expected Behavior

KEDA creates HPA successfully even when the name of ScaledObject is longer than 63 characters.

Actual Behavior

KEDA fails to create HPA when the name of ScaledObject is longer than 63 characters.

Steps to Reproduce the Problem

  1. Set up ScaledObject with a long name of more than 63 characters
  2. Check HPA and ScaledObject

This is the ScaledObject spec to reproduce the issue.

kubectl apply -f - <<EOF
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
spec:
  minReplicaCount: 1
  maxReplicaCount: 10
  scaleTargetRef:
    name: nginx
  triggers:
  - type: cpu
    metricType: Utilization
    metadata:
      type: Utilization
      value: "60"
EOF

Here is outputs when checking HPA/ScaledObject.

❯ kubectl get hpa
No resources found in default namespace.

❯ kubectl describe so
Name:         this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Namespace:    default
Labels:       <none>
Annotations:  <none>
API Version:  keda.sh/v1alpha1
Kind:         ScaledObject
Metadata:
  Creation Timestamp:  2024-11-28T04:10:24Z
  Finalizers:
    finalizer.keda.sh
  Generation:        1
  Resource Version:  3315
  UID:               9f9e91ea-c84e-4553-8b4f-8aa9697cff12
Spec:
  Max Replica Count:  10
  Min Replica Count:  1
  Scale Target Ref:
    Name:  nginx
  Triggers:
    Metadata:
      Type:       Utilization
      Value:      60
    Metric Type:  Utilization
    Type:         cpu
Status:
  Conditions:
    Message:  failed to update ScaledObject with scaledObjectName label
    Reason:   ScaledObjectCheckFailed
    Status:   False
    Type:     Ready
    Message:  ScaledObject check failed
    Reason:   UnknownState
    Status:   Unknown
    Type:     Active
    Message:  No fallbacks are active on this scaled object
    Reason:   NoFallbackFound
    Status:   False
    Type:     Fallback
    Status:   Unknown
    Type:     Paused
Events:
  Type     Reason                   Age                   From           Message
  ----     ------                   ----                  ----           -------
  Warning  ScaledObjectCheckFailed  69s (x16 over 3m54s)  keda-operator  failed to update ScaledObject with scaledObjectName label

Logs from KEDA operator

2024-11-28T04:10:24Z	ERROR	failed to update ScaledObject with scaledObjectName label	{"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","namespace":"default"}, "namespace": "default", "name": "this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "reconcileID": "3abc307a-e62a-4142-9ab8-f0b314cd4764", "error": "ScaledObject.keda.sh \"this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" is invalid: metadata.labels: Invalid value: \"this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\": must be no more than 63 characters"}
github.com/kedacore/keda/v2/controllers/keda.(*ScaledObjectReconciler).Reconcile
	/workspace/controllers/keda/scaledobject_controller.go:195
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Reconcile
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:116
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:303
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224

2024-11-28T04:10:24Z	ERROR	Reconciler error	{"controller": "scaledobject", "controllerGroup": "keda.sh", "controllerKind": "ScaledObject", "ScaledObject": {"name":"this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","namespace":"default"}, "namespace": "default", "name": "this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "reconcileID": "3abc307a-e62a-4142-9ab8-f0b314cd4764", "error": "ScaledObject.keda.sh \"this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\" is invalid: metadata.labels: Invalid value: \"this-is-64-characters-name-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\": must be no more than 63 characters"}
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).reconcileHandler
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:316
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).processNextWorkItem
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:263
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller[...]).Start.func2.2
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:224

KEDA Version

2.16.0

Kubernetes Version

1.29

Platform

Any

Scaler Details

Any, but I used cpu scaler for testing.

Anything else?

This issue is also mentioned #2915 (comment).

@s-shirayama s-shirayama added the bug Something isn't working label Nov 28, 2024
@omerap12 omerap12 linked a pull request Nov 30, 2024 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To Triage
Development

Successfully merging a pull request may close this issue.

1 participant