Skip to content

Fix: Prefixes in envFrom within deployment specs are being ignored#6757

Merged
JorTurFer merged 5 commits intokedacore:mainfrom
araminian:fix-ignoring-prefix-on-envfrom
May 13, 2025
Merged

Fix: Prefixes in envFrom within deployment specs are being ignored#6757
JorTurFer merged 5 commits intokedacore:mainfrom
araminian:fix-ignoring-prefix-on-envfrom

Conversation

@araminian
Copy link
Contributor

@araminian araminian commented May 4, 2025

Issue

When envFrom includes a prefix setting, the scale resolver ignores this prefix and adds environment variable keys to the ScalerConfig without the prefix.

apiVersion: v1
kind: ConfigMap
metadata:
  name: kafka-config
data:
  BOOTSTRAP_SERVERS: "kafka.example.com"
  PORT: "9092"
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dummy-app
  labels:
    app: dummy-app
spec:
  selector:
    matchLabels:
      app: dummy-app
  template:
    metadata:
      labels:
        app: dummy-app
    spec:
      containers:
      - name: app-container
        image: nginx:latest
        envFrom:
        - configMapRef:
            name: kafka-config
          prefix: "KAFKA_" # Having PREFIX

resolveEnv is ignoring the prefix setting and loading envs without prefix:
Actual:

BOOTSTRAP_SERVERS
PORT

Desired:

KAFKA_BOOTSTRAP_SERVERS
KAFKA_PORT

Provide a description of what has been changed.

FIX

resolveEnv correctly applies prefixes to keys when a prefix is specified.

  1. Get prefix, prefix is an empty string if not set
  2. Prefix Env Key : prefix + k

Checklist

Fixes #6728

araminian added 4 commits May 4, 2025 13:37
When envFrom includes a prefix setting, the scale resolver ignores this prefix and adds environment variable keys to the ScalerConfig without the prefix.

This fix modifies resolveEnv to correctly apply prefixes to keys when a prefix is specified.

Signed-off-by: araminian <rmin.aminian@gmail.com>
Signed-off-by: araminian <rmin.aminian@gmail.com>
Signed-off-by: araminian <rmin.aminian@gmail.com>
Signed-off-by: araminian <rmin.aminian@gmail.com>
@araminian araminian marked this pull request as ready for review May 5, 2025 07:27
@araminian araminian requested a review from a team as a code owner May 5, 2025 07:27
Copy link
Member

@wozniakjan wozniakjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thank you!

@wozniakjan
Copy link
Member

wozniakjan commented May 6, 2025

/run-e2e
Update: You can check the progress here

Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
@JorTurFer
Copy link
Member

JorTurFer commented May 13, 2025

/run-e2e rabbit
Update: You can check the progress here

@JorTurFer JorTurFer enabled auto-merge (squash) May 13, 2025 19:36
@JorTurFer JorTurFer merged commit 033f46d into kedacore:main May 13, 2025
18 checks passed
dpochopsky pushed a commit to dpochopsky/keda that referenced this pull request Sep 12, 2025
…edacore#6757)

* fix: Prefixes in envFrom within deployment specs are being ignored

When envFrom includes a prefix setting, the scale resolver ignores this prefix and adds environment variable keys to the ScalerConfig without the prefix.

This fix modifies resolveEnv to correctly apply prefixes to keys when a prefix is specified.

Signed-off-by: araminian <rmin.aminian@gmail.com>

* Reorder changelog

Signed-off-by: araminian <rmin.aminian@gmail.com>

* Use existing test function

Signed-off-by: araminian <rmin.aminian@gmail.com>

* Adjust comment

Signed-off-by: araminian <rmin.aminian@gmail.com>

---------

Signed-off-by: araminian <rmin.aminian@gmail.com>
Signed-off-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: David Pochopsky <david.pochopsky@united.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keda ignoring prefixes when resolving envvars

3 participants