Skip to content

fix: resolve secondary workload HPA autoscaling and metadata labels (#6982) - #7056

Open
tushar-hub wants to merge 1 commit into
devtron-labs:mainfrom
tushar-hub:fix/secondary-workload-hpa-6982
Open

tushar-hub wants to merge 1 commit into
devtron-labs:mainfrom
tushar-hub:fix/secondary-workload-hpa-6982

Conversation

@tushar-hub

Copy link
Copy Markdown

Description

When configuring secondary workloads with Horizontal Pod Autoscaler (HPA) enabled, the rendered secondary HPA resource was missing the standard Devtron metadata tracking labels (appId, envId, app, chart, release, and appLabels), and had empty minReplicas and maxReplicas values when defaults were not explicitly duplicated under secondaryWorkload.autoscaling. Furthermore, secondaryWorkload and its nested autoscaling configurations were absent from schema.json, causing GUI schema validation errors and ambiguous workload tracking warnings in the cluster.

This PR addresses this by:

  1. Adding complete metadata labels (appId, envId, app, chart, release, appLabels) to the secondary HPA resource in templates/hpa.yaml, with proper inheritance for custom labels/annotations and support for dedicated overrides.
  2. Providing fallback defaults for minReplicas, maxReplicas, TargetCPUUtilizationPercentage, and TargetMemoryUtilizationPercentage so that enabling secondary workload autoscaling never renders invalid or empty spec fields.
  3. Supporting secondaryWorkload.containerName override in both templates/deployment.yaml and templates/hpa.yaml container metrics.
  4. Adding secondaryWorkload and its full autoscaling schema definition to schema.json.
  5. Updating default values in values.yaml for clear documentation and predictability.

Fixes #6982

How Has This Been Tested?

  • Verified with helm lint across updated deployment charts (0 errors).
  • Validated template rendering with helm template under multiple scenarios:
    • Default values (HPA disabled)
    • Primary HPA only
    • Both primary and secondary HPA enabled with defaults
    • Secondary HPA enabled with custom scaling targets (MinReplicas, MaxReplicas, target CPU/memory)
    • Custom container name override (secondaryWorkload.containerName) reflected in deployment container and HPA containerResource metric
    • Custom annotations and labels inheritance and overrides
    • test_values.yaml end-to-end rendering
  • Validated schema.json syntax with JSON schema parser.

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?

Fixed Horizontal Pod Autoscaler (HPA) rendering and schema definitions for secondary workloads in deployment reference charts.

@bito-code-review

Copy link
Copy Markdown

Bito Review Skipped - Source Branch Not Found

Bito didn't review this change because the pull request is no longer valid. It may have been merged, or the source/target branch may no longer exist.

@tushar-hub
tushar-hub force-pushed the fix/secondary-workload-hpa-6982 branch from 9b88640 to 5cb32d5 Compare October 8, 2026 04:51
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes consistently resolve the reported rendering, metadata, override, and schema gaps across all targeted chart versions.

0 open findings

What changed in this PR

Fixes secondary workload HPA rendering and GUI schema support across deployment chart versions 4.20–4.22.

Changes:

  • Adds secondary HPA metadata, defaults, overrides, and fallback behavior.
  • Supports secondary container-name overrides.
  • Defines secondary workload autoscaling schemas.
File Description
deployment-chart_4-20-0/​values.yaml Adds secondary HPA defaults and container override.
deployment-chart_4-20-0/​templates/​hpa.yaml Corrects secondary HPA rendering.
deployment-chart_4-20-0/​templates/​deployment.yaml Applies secondary container name.
deployment-chart_4-20-0/​schema.json Adds secondary workload schema.
deployment-chart_4-21-0/​values.yaml Adds secondary HPA defaults.
deployment-chart_4-21-0/​templates/​hpa.yaml Corrects secondary HPA rendering.
deployment-chart_4-21-0/​templates/​deployment.yaml Applies secondary container name.
deployment-chart_4-21-0/​schema.json Adds secondary workload schema.
deployment-chart_4-22-0/​values.yaml Adds secondary HPA defaults.
deployment-chart_4-22-0/​templates/​hpa.yaml Corrects secondary HPA rendering.
deployment-chart_4-22-0/​templates/​deployment.yaml Applies secondary container name.
deployment-chart_4-22-0/​schema.json Adds secondary workload schema.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

This branch has not been deployed

No deployments
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.

Bug: HPA does not work correctly with secondaryWorkload when autoscaling is enabled (Deployment Chart 4.2)

2 participants