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

Newline character added to Prometheus Custom Auth #4960

Closed
Amir-Wollman opened this issue Sep 11, 2023 · 1 comment · Fixed by #4959
Closed

Newline character added to Prometheus Custom Auth #4960

Amir-Wollman opened this issue Sep 11, 2023 · 1 comment · Fixed by #4959
Labels
bug Something isn't working

Comments

@Amir-Wollman
Copy link
Contributor

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

@Amir-Wollman Amir-Wollman added the bug Something isn't working label Sep 11, 2023
@Amir-Wollman
Copy link
Contributor Author

Fixed in PR #4959

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: Ready To Ship
1 participant