Skip to content

fix(status): correct history snapshot fields for helm-controller compatibility#10

Merged
kvaps merged 1 commit into
mainfrom
fix/history-snapshot-fields
Jan 27, 2026
Merged

fix(status): correct history snapshot fields for helm-controller compatibility#10
kvaps merged 1 commit into
mainfrom
fix/history-snapshot-fields

Conversation

@kvaps
Copy link
Copy Markdown
Member

@kvaps kvaps commented Jan 27, 2026

Summary

Fix critical bug causing helm-controller v0.37.0+ to unexpectedly uninstall HelmReleases after cozyhr apply.

The newHistoryEntry function was incorrectly setting several fields in status.history Snapshot:

  • Name: was set to chartName (e.g., "tenant") instead of release name (e.g., "tenant-root")
  • Namespace: was set to hr.Namespace instead of hr.GetReleaseNamespace()
  • Version: was always 1 instead of incrementing from previous history entry
  • History order: was appended to end instead of prepended (Flux's History.Latest() returns first element)

Root Cause

When helm-controller reconciles, it calls ReleaseTargetChanged() which compares:

  • obj.GetReleaseName() (from spec)
  • cur.Name (from status.history[0])

If these don't match, helm-controller triggers an uninstall of the "old" release before installing the "new" one. This caused tenant HelmReleases to be deleted unexpectedly.

Test plan

  • Verify cozyhr apply no longer triggers uninstall on existing HelmReleases
  • Verify history entry has correct name matching spec.releaseName or metadata.name
  • Verify history entry version increments correctly

Summary by CodeRabbit

  • Bug Fixes

    • Fixed release version tracking to increment from existing history rather than defaulting to version 1.
    • Corrected release history ordering to show latest deployments first.
  • Improvements

    • Release history entries now include first-deployed and last-deployed timestamps.
    • History entries now include a deployment status (e.g., "deployed") and use the actual release name/namespace when shown.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

History entry creation was changed to compute the next version from existing entries, set Snapshot Name/Namespace from the HelmRelease, populate Version, FirstDeployed, LastDeployed, and Status, and prepend new snapshots to Status.History (latest-first ordering).

Changes

Cohort / File(s) Summary
History Entry Management
main.go
newHistoryEntry signature changed to accept chartName and compute Version by inspecting existing history; Snapshot now uses hr.GetReleaseName()/hr.GetReleaseNamespace(), and includes FirstDeployed, LastDeployed, and Status. markSuccess now prepends the new Snapshot to hr.Status.History (latest-first).
API Type Changes
api/v2/types.go, .../v2/*.go
Public struct v2.Snapshot extended with FirstDeployed metav1.Time, LastDeployed metav1.Time, and Status string to carry deployment timestamps and status in history entries.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibble on code, then hop with glee,

Versions climb up the release-history tree,
Timestamps tick where deployments lie,
Latest-first now greets the eye,
A rabbit's wink — tidy and spry.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: correcting history snapshot fields for helm-controller compatibility, which matches the core bug fix described in the PR objectives.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @kvaps, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug that caused helm-controller versions 0.37.0 and above to unexpectedly uninstall existing HelmReleases after a cozyhr apply operation. The changes ensure that the status.history snapshot fields, specifically Name, Namespace, and Version, are correctly populated and that history entries are ordered appropriately. This prevents unintended release deletions and ensures proper compatibility with the updated helm-controller reconciliation logic.

Highlights

  • HelmRelease History Snapshot Correction: The Name field in the status.history Snapshot is now correctly set to match hr.GetReleaseName(), resolving an issue where it was previously set to the chart name.
  • Namespace Field Alignment: The Namespace field in the status.history Snapshot has been updated to use hr.GetReleaseNamespace(), ensuring it accurately reflects the release's namespace.
  • Version Increment Logic: The Version field in the status.history Snapshot now correctly increments based on the previous history entry, instead of always being 1.
  • History Order Adjustment: New history entries are now prepended to hr.Status.History, aligning with Flux's History.Latest() function which expects the latest entry to be the first element.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@kvaps kvaps marked this pull request as ready for review January 27, 2026 15:08
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a critical bug that caused helm-controller to unexpectedly uninstall HelmReleases after a cozyhr apply. The changes correctly update the status.history snapshot fields, including Name, Namespace, and Version, to be compatible with helm-controller's expectations. Additionally, the history update logic is corrected to prepend new entries, ensuring History.Latest() works as intended. The fix appears solid and directly addresses the issues outlined in the pull request description. I have added one suggestion for a minor refactoring to improve efficiency by avoiding a redundant function call.

Comment thread main.go Outdated
…atibility

The newHistoryEntry function was incorrectly setting several fields in the
status.history Snapshot, causing helm-controller v0.37.0+ to trigger
uninstall due to ReleaseTargetChanged detection:

- Name: was set to chartName instead of release name
- Namespace: was set to hr.Namespace instead of release namespace
- Version: was always 1 instead of incrementing from previous
- History order: was appended to end instead of prepended

When helm-controller compares obj.GetReleaseName() with cur.Name from
status.history, a mismatch triggers an uninstall of the "old" release
before installing the "new" one. This caused tenant HelmReleases to be
deleted unexpectedly.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
@kvaps kvaps force-pushed the fix/history-snapshot-fields branch from 770c178 to d83d0f1 Compare January 27, 2026 15:31
@kvaps kvaps merged commit 8c85f2c into main Jan 27, 2026
2 of 3 checks passed
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