Skip to content

K8s: Rollback Job scaling strategy default in chart value#3168

Open
VietND96 wants to merge 1 commit into
trunkfrom
revert-chart
Open

K8s: Rollback Job scaling strategy default in chart value#3168
VietND96 wants to merge 1 commit into
trunkfrom
revert-chart

Conversation

@VietND96

@VietND96 VietND96 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Helm chart: default KEDA ScaledJob scalingStrategy by leaving strategy unset

⚙️ Configuration changes 📝 Documentation 🧪 Tests 🕐 10-20 Minutes

Grey Divider

AI Description

• Revert ScaledJob scalingStrategy default to unset, deferring to KEDA defaults.
• Align chart test harness to pass an empty scaling strategy by default.
• Document SessionQueue external datastore (Redis) values and defaults.
Diagram

graph TD
  A["values.yaml"] --> B["autoscaling values"] --> C["_helpers.tpl autoscalingTemplate"] --> D["KEDA ScaledJob spec"]
  E["chart_test.sh"] --> F["Makefile test_k8s_* target"] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Set strategy explicitly to "default" (string)
  • ➕ Makes intent explicit in rendered YAML (if chart emits the field).
  • ➕ Avoids relying on template empty-field filtering semantics.
  • ➖ May not match KEDA API expectations if "default" isn’t a valid enum value.
  • ➖ Still differs from KEDA’s behavior when the field is omitted entirely.
2. Keep "accurate" as chart default
  • ➕ Preserves prior behavior deterministically across KEDA versions.
  • ➖ Overrides KEDA defaults even when users expect stock behavior.
  • ➖ May cause surprises if KEDA changes recommended default strategy.
3. Add values-schema validation / enum docs for strategy
  • ➕ Prevents invalid strategy values early (helm lint/install time).
  • ➕ Clarifies supported options and expected behavior.
  • ➖ More maintenance (must track KEDA spec changes).
  • ➖ Doesn’t directly address the goal of deferring to KEDA defaults unless combined with empty/unset semantics.

Recommendation: Leaving the strategy empty/unset is the best way to truly defer to KEDA defaults, especially since the chart’s template filters empty fields (so the scalingStrategy section can be omitted). Consider adjusting the README wording to clarify that the chart sets the value to empty to use KEDA defaults (rather than implying the literal string "default").

Files changed (5) +9 / -5

Tests (2) +2 / -2
MakefileDefault SCALING_STRATEGY to empty for K8s autoscaling job tests +1/-1

Default SCALING_STRATEGY to empty for K8s autoscaling job tests

• Updates the k8s autoscaling job-count strategy default test target to pass an empty SCALING_STRATEGY, matching the chart’s new default behavior (defer to KEDA).

Makefile

chart_test.shDefault SCALING_STRATEGY env var to empty in chart tests +1/-1

Default SCALING_STRATEGY env var to empty in chart tests

• Updates the chart test harness to default SCALING_STRATEGY to an empty string, aligning test execution with the chart’s KEDA-default scaling strategy behavior.

tests/charts/make/chart_test.sh

Documentation (2) +6 / -2
CONFIGURATION.mdDocument SessionQueue externalDatastore (Redis) values +5/-1

Document SessionQueue externalDatastore (Redis) values

• Adds missing configuration table entries for components.sessionQueue.externalDatastore, including enablement flag, backend selection, and Redis settings with defaults.

charts/selenium-grid/CONFIGURATION.md

README.mdUpdate narrative for ScaledJob scalingStrategy default behavior +1/-1

Update narrative for ScaledJob scalingStrategy default behavior

• Adjusts README guidance to indicate the chart relies on KEDA’s default scaling behavior rather than enforcing "accurate" via values.

charts/selenium-grid/README.md

Other (1) +1 / -1
values.yamlUnset scaledJobOptions.scalingStrategy.strategy to use KEDA default +1/-1

Unset scaledJobOptions.scalingStrategy.strategy to use KEDA default

• Changes autoscaling.scaledJobOptions.scalingStrategy.strategy from "accurate" to an empty value so the rendered ScaledJob spec can omit the field and fall back to KEDA defaults.

charts/selenium-grid/values.yaml

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Empty scaling strategy emitted 🐞 Bug ≡ Correctness
Description
charts/selenium-grid/values.yaml now defaults autoscaling.scaledJobOptions.scalingStrategy.strategy
to "", and the autoscalingTemplate helper will still emit the non-empty scalingStrategy map into
ScaledJob specs. This produces rendered ScaledJobs with scalingStrategy.strategy: "" (not an omitted
field and not the repo’s documented/tested "default" strategy), so enabling autoscaling with
defaults yields a misconfigured ScaledJob spec.
Code

charts/selenium-grid/values.yaml[R1197-1200]

    scalingStrategy:
      # -- Scaling strategy for KEDA ScaledJob - https://keda.sh/docs/latest/reference/scaledjob-spec/#scalingstrategy
-      strategy: "accurate"
+      strategy: ""
    # -- Number of Completed jobs should be kept
Evidence
The default value is now empty in values.yaml, but the helper renders nested non-empty maps without
pruning empty inner strings, so the rendered ScaledJob spec will include an explicit empty strategy;
repo CI and reference values consistently use a concrete strategy value ("default").

charts/selenium-grid/values.yaml[1196-1203]
charts/selenium-grid/templates/_helpers.tpl[239-279]
charts/selenium-grid/templates/chrome-node-scaledjobs.yaml[23-31]
tests/charts/ci/JobAutoscaling-values.yaml[5-12]
tests/charts/refValues/simplex-minikube.yaml[26-38]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The chart default sets `autoscaling.scaledJobOptions.scalingStrategy.strategy` to an empty string, but the template emits the `scalingStrategy` object anyway, resulting in rendered ScaledJobs containing `scalingStrategy.strategy: ""`.

## Issue Context
The autoscaling template only filters empty values at the top level; nested maps like `scalingStrategy: {strategy: ""}` are considered non-empty and are rendered.

## Fix Focus Areas
- charts/selenium-grid/values.yaml[1196-1200]
- charts/selenium-grid/templates/_helpers.tpl[239-279]
- charts/selenium-grid/CONFIGURATION.md[457-460]

## Suggested fix
Either:
1) Set the chart default to the concrete strategy used by repo examples/CI (e.g., `strategy: "default"`), OR
2) If the intent is to rely on KEDA defaults, change defaults/templates so `scalingStrategy` is *omitted* when `strategy` is empty (e.g., default `scalingStrategy: {}` and/or explicitly `unset`/drop `scalingStrategy` when `.strategy` is empty, including nested cleanup).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Tests override strategy empty 🐞 Bug ☼ Reliability
Description
tests/charts/make/chart_test.sh now defaults SCALING_STRATEGY to "" and still always appends `--set
autoscaling.scaledJobOptions.scalingStrategy.strategy=${SCALING_STRATEGY}` when autoscaling is
enabled. This forces chart test runs to render an explicit empty strategy unless the environment
variable is set, making tests diverge from the repo’s reference values and intended defaults.
Code

tests/charts/make/chart_test.sh[28]

+SCALING_STRATEGY=${SCALING_STRATEGY:-""}
Evidence
The script now defaults SCALING_STRATEGY to empty and then always injects it into Helm via --set;
the Makefile target also defaults SCALING_STRATEGY to empty for this test path.

tests/charts/make/chart_test.sh[16-31]
tests/charts/make/chart_test.sh[221-233]
Makefile[1430-1435]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The test harness defaults `SCALING_STRATEGY` to an empty string and unconditionally passes it via `--set ...strategy=${SCALING_STRATEGY}` when autoscaling is enabled.

## Issue Context
Passing `--set key=` results in an explicit empty string value, overriding chart defaults and any values-file-provided strategy.

## Fix Focus Areas
- tests/charts/make/chart_test.sh[16-33]
- tests/charts/make/chart_test.sh[221-233]
- Makefile[1430-1435]

## Suggested fix
Only append `--set autoscaling.scaledJobOptions.scalingStrategy.strategy=...` when `SCALING_STRATEGY` is non-empty; otherwise omit the flag entirely so chart defaults/values files drive behavior. Optionally update the Makefile target to not set `SCALING_STRATEGY` at all unless explicitly requested.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

3. Docs default inconsistent 🐞 Bug ⚙ Maintainability
Description
README.md now claims the chart keeps autoscaling.scaledJobOptions.scalingStrategy.strategy as
default, but CONFIGURATION.md and values.yaml list the default as an empty string. This leaves
users without a single source of truth for what the chart actually renders by default.
Code

charts/selenium-grid/README.md[232]

+Expected that with default configuration in KEDA resource, autoscaling behavior should be correct. Hence, in chart values, we keep the config key `autoscaling.scaledJobOptions.scalingStrategy.strategy` is `default`.
Evidence
The README text asserts default, while both CONFIGURATION.md and values.yaml show an empty-string
default for the same key.

charts/selenium-grid/README.md[228-233]
charts/selenium-grid/CONFIGURATION.md[450-460]
charts/selenium-grid/values.yaml[1196-1200]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
README says the default strategy is `default`, but CONFIGURATION.md and values.yaml show `""`.

## Issue Context
This mismatch is user-facing and also conflicts with repo reference values that set `strategy: default`.

## Fix Focus Areas
- charts/selenium-grid/README.md[228-233]
- charts/selenium-grid/CONFIGURATION.md[457-460]
- charts/selenium-grid/values.yaml[1196-1200]

## Suggested fix
Make README, CONFIGURATION.md, and values.yaml all reflect the same default behavior (either a concrete `default` value, or explicitly document that the field is omitted/unset and ensure templates omit it).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment on lines 1197 to 1200
scalingStrategy:
# -- Scaling strategy for KEDA ScaledJob - https://keda.sh/docs/latest/reference/scaledjob-spec/#scalingstrategy
strategy: "accurate"
strategy: ""
# -- Number of Completed jobs should be kept

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. Empty scaling strategy emitted 🐞 Bug ≡ Correctness

charts/selenium-grid/values.yaml now defaults autoscaling.scaledJobOptions.scalingStrategy.strategy
to "", and the autoscalingTemplate helper will still emit the non-empty scalingStrategy map into
ScaledJob specs. This produces rendered ScaledJobs with scalingStrategy.strategy: "" (not an omitted
field and not the repo’s documented/tested "default" strategy), so enabling autoscaling with
defaults yields a misconfigured ScaledJob spec.
Agent Prompt
## Issue description
The chart default sets `autoscaling.scaledJobOptions.scalingStrategy.strategy` to an empty string, but the template emits the `scalingStrategy` object anyway, resulting in rendered ScaledJobs containing `scalingStrategy.strategy: ""`.

## Issue Context
The autoscaling template only filters empty values at the top level; nested maps like `scalingStrategy: {strategy: ""}` are considered non-empty and are rendered.

## Fix Focus Areas
- charts/selenium-grid/values.yaml[1196-1200]
- charts/selenium-grid/templates/_helpers.tpl[239-279]
- charts/selenium-grid/CONFIGURATION.md[457-460]

## Suggested fix
Either:
1) Set the chart default to the concrete strategy used by repo examples/CI (e.g., `strategy: "default"`), OR
2) If the intent is to rely on KEDA defaults, change defaults/templates so `scalingStrategy` is *omitted* when `strategy` is empty (e.g., default `scalingStrategy: {}` and/or explicitly `unset`/drop `scalingStrategy` when `.strategy` is empty, including nested cleanup).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

AUTOSCALING_COOLDOWN_PERIOD=${AUTOSCALING_COOLDOWN_PERIOD:-"1800"}
ENABLE_VIDEO_RECORDER=${ENABLE_VIDEO_RECORDER:-"true"}
SCALING_STRATEGY=${SCALING_STRATEGY:-"accurate"}
SCALING_STRATEGY=${SCALING_STRATEGY:-""}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remediation recommended

2. Tests override strategy empty 🐞 Bug ☼ Reliability

tests/charts/make/chart_test.sh now defaults SCALING_STRATEGY to "" and still always appends `--set
autoscaling.scaledJobOptions.scalingStrategy.strategy=${SCALING_STRATEGY}` when autoscaling is
enabled. This forces chart test runs to render an explicit empty strategy unless the environment
variable is set, making tests diverge from the repo’s reference values and intended defaults.
Agent Prompt
## Issue description
The test harness defaults `SCALING_STRATEGY` to an empty string and unconditionally passes it via `--set ...strategy=${SCALING_STRATEGY}` when autoscaling is enabled.

## Issue Context
Passing `--set key=` results in an explicit empty string value, overriding chart defaults and any values-file-provided strategy.

## Fix Focus Areas
- tests/charts/make/chart_test.sh[16-33]
- tests/charts/make/chart_test.sh[221-233]
- Makefile[1430-1435]

## Suggested fix
Only append `--set autoscaling.scaledJobOptions.scalingStrategy.strategy=...` when `SCALING_STRATEGY` is non-empty; otherwise omit the flag entirely so chart defaults/values files drive behavior. Optionally update the Makefile target to not set `SCALING_STRATEGY` at all unless explicitly requested.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Settings that KEDA [ScaledJob spec](https://keda.sh/docs/latest/concepts/scaling-jobs/#scaledjob-spec) supports can be set via `autoscaling.scaledJobOptions`.

Expected that with default configuration in KEDA resource, autoscaling behavior should be correct. Hence, in chart values, we keep the config key `autoscaling.scaledJobOptions.scalingStrategy.strategy` is `accurate`.
Expected that with default configuration in KEDA resource, autoscaling behavior should be correct. Hence, in chart values, we keep the config key `autoscaling.scaledJobOptions.scalingStrategy.strategy` is `default`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Informational

3. Docs default inconsistent 🐞 Bug ⚙ Maintainability

README.md now claims the chart keeps autoscaling.scaledJobOptions.scalingStrategy.strategy as
default, but CONFIGURATION.md and values.yaml list the default as an empty string. This leaves
users without a single source of truth for what the chart actually renders by default.
Agent Prompt
## Issue description
README says the default strategy is `default`, but CONFIGURATION.md and values.yaml show `""`.

## Issue Context
This mismatch is user-facing and also conflicts with repo reference values that set `strategy: default`.

## Fix Focus Areas
- charts/selenium-grid/README.md[228-233]
- charts/selenium-grid/CONFIGURATION.md[457-460]
- charts/selenium-grid/values.yaml[1196-1200]

## Suggested fix
Make README, CONFIGURATION.md, and values.yaml all reflect the same default behavior (either a concrete `default` value, or explicitly document that the field is omitted/unset and ensure templates omit it).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

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.

1 participant