Skip to content

fix: apply HelmReleaseName truncation in releaseKey for GC comparison#5302

Merged
0xavi0 merged 1 commit into
rancher:mainfrom
nilsalex:fix/cleanup-helm-release-name-truncation
Jul 3, 2026
Merged

fix: apply HelmReleaseName truncation in releaseKey for GC comparison#5302
0xavi0 merged 1 commit into
rancher:mainfrom
nilsalex:fix/cleanup-helm-release-name-truncation

Conversation

@nilsalex

Copy link
Copy Markdown
Contributor

Refers to #5261

When no explicit Helm.ReleaseName is configured, the deployer derives the helm release name via names.HelmReleaseName(bundleID), which truncates names longer than 53 characters and appends a 5-char hash. The releaseKey function in cleanup.go was using bd.Name directly, causing a mismatch against the actual truncated release name stored in helm secrets.

This caused the garbage collector to incorrectly flag valid releases as unknown and delete them, logging:

"Deleting unknown bundle ID, helm uninstall" ...
"release":"default/...-742e3","expectedRelease":"default/...-5nj4is"

Fix: apply names.HelmReleaseName() in releaseKey when no explicit release name is set, mirroring what deployer.getOpts() does.

Copilot AI review requested due to automatic review settings June 18, 2026 08:20
@nilsalex nilsalex requested a review from a team as a code owner June 18, 2026 08:20

Copilot AI left a comment

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.

Pull request overview

This pull request fixes a Helm release-name mismatch in the agent garbage collector by ensuring the GC computes the expected release key using the same truncation/sanitization logic as the Helm deployer when helm.releaseName is not explicitly set. This prevents valid releases (especially for BundleDeployment names > 53 characters) from being incorrectly treated as “unknown” and uninstalled.

Changes:

  • Apply names.HelmReleaseName(bd.Name) in releaseKey() when no explicit Helm.ReleaseName is configured.
  • Add a regression test covering the “no explicit releaseName + long bundle ID” case to ensure the GC does not delete the valid release.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/cmd/agent/deployer/cleanup/cleanup.go Aligns GC’s expected release key derivation with deployer behavior by applying HelmReleaseName when releaseName is implicit.
internal/cmd/agent/deployer/cleanup/cleanup_test.go Adds a focused test to prevent regressions for long BundleDeployment names without an explicit Helm release name.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kkaempf kkaempf added this to the v2.16.0 milestone Jun 18, 2026
@weyfonk weyfonk modified the milestones: v2.16.0, v2.15.1 Jun 19, 2026
When no explicit Helm.ReleaseName is configured, the deployer derives the
helm release name via names.HelmReleaseName(bundleID), which truncates names
longer than 53 characters and appends a 5-char hash. The releaseKey function
in cleanup.go was using bd.Name directly, causing a mismatch against the
actual truncated release name stored in helm secrets.

This caused the garbage collector to incorrectly flag valid releases as
unknown and delete them, logging:

  "Deleting unknown bundle ID, helm uninstall" ...
  "release":"default/...-742e3","expectedRelease":"default/...-5nj4is"

Fix: apply names.HelmReleaseName() in releaseKey when no explicit release
name is set, mirroring what deployer.getOpts() does.
@nilsalex nilsalex force-pushed the fix/cleanup-helm-release-name-truncation branch from 33010df to 5ee363e Compare June 29, 2026 06:44

@0xavi0 0xavi0 left a comment

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.

LGTM

@0xavi0 0xavi0 merged commit 665c548 into rancher:main Jul 3, 2026
36 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants