Skip to content

Newline character added to Prometheus Custom Auth #4960

@Amir-Wollman

Description

@Amir-Wollman

Report

It seems whenever using a secretRef with Prometheus CustomAuth auth type, a new line is either added or not removed from the actual values.

Expected Behavior

Using the below manifests, Keda should be able to retrieve metrics from Prometheus:

apiVersion: v1
items:
- apiVersion: keda.sh/v1alpha1
  kind: ClusterTriggerAuthentication
  metadata:
    finalizers:
    - finalizer.keda.sh
    name: keda-prom-creds
  spec:
    secretTargetRef:
    - key: PRIVATE_KEY
      name: secret-keys
      parameter: customAuthValue
    - key: authToken
      name: secret-keys
      parameter: customAuthHeader
kind: List

where value is:

  authToken: dG9rZW4K (== "token")

Actual Behavior

Keda operator fails with error: net/http: invalid header field name \"token\\n\"

2023-09-07T06:33:13Z	ERROR	scale_handler	error getting metric for scaler	{"scaledObject.Namespace": "hpa-tenant", "scaledObject.Name": "prometheus-so-test-metric", "scaler": "prometheusScaler", "error": "Get \"https://prom-server.com/api/v1/query?query=sum%28rate%28container_cpu_usage_seconds_total%7Bnamespace%3D~%22.%2Ahpa-tenant.%2A%22%2Ccontainer%3D%22dal%22%7D%5B5m%5D%29+%2F+%28kube_pod_container_resource_limits%7Bnamespace%3D~%22.%2Ahpa-tenant.%2A%22%2Ccontainer%3D%22dal%22%2Cresource%3D%22cpu%22%7D%29%29+by+%28container%2C+namespace%29+%2A+100&time=2023-09-07T06:33:13Z\": net/http: invalid header field name \"token\\n\""}

Steps to Reproduce the Problem

  1. Create a secret (in this example was created with ExternalSecrets)
  2. Reference the secret in TriggerAuthentication

Logs from KEDA operator

2023-09-07T06:33:13Z	ERROR	scale_handler	error getting metric for scaler	{"scaledObject.Namespace": "hpa-tenant", "scaledObject.Name": "prometheus-so-test-metric", "scaler": "prometheusScaler", "error": "Get \"https://prom-server.com/api/v1/query?query=sum%28rate%28container_cpu_usage_seconds_total%7Bnamespace%3D~%22.%2Ahpa-tenant.%2A%22%2Ccontainer%3D%22dal%22%7D%5B5m%5D%29+%2F+%28kube_pod_container_resource_limits%7Bnamespace%3D~%22.%2Ahpa-tenant.%2A%22%2Ccontainer%3D%22dal%22%2Cresource%3D%22cpu%22%7D%29%29+by+%28container%2C+namespace%29+%2A+100&time=2023-09-07T06:33:13Z\": net/http: invalid header field name \"token\\n\""}

KEDA Version

2.11.1

Kubernetes Version

1.27

Platform

Amazon Web Services

Scaler Details

Prometheus

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Ready To Ship

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions