Skip to content

Fix #372: Fetch and compare deployed Helm values in Read to detect out-of-band drift - #1856

Open
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/372-drift-detection
Open

Fix #372: Fetch and compare deployed Helm values in Read to detect out-of-band drift#1856
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/372-drift-detection

Conversation

@dennismdejong

Copy link
Copy Markdown

Description

When values of a helm release are modified outside of Terraform (e.g., via helm upgrade --set), the provider does not detect the drift. The Read function returns the state values rather than the actual deployed values.

Root Cause

In the Read function, setReleaseAttributes only updates metadata.values (a computed-only field) but never compares or updates state.Values, state.Set, state.SetSensitive, or state.SetList against the actual deployed values from release.Config. This means out-of-band changes via helm upgrade are invisible to Terraform.

Fix

In the Read function, after setReleaseAttributes, the fix:

  1. Fetches the deployed release's merged values from release.Config
  2. Computes the expected merged values from the Terraform state using getValues(ctx, &state)
  3. Compares them using reflect.DeepEqual
  4. If they differ, marshals the deployed values to YAML and updates state.Values
  5. This causes Terraform to detect the diff during planning and trigger an update

This also fixes #472 (drift from failed applies) - when a helm upgrade fails partway, the partially-applied values cause a mismatch that will be detected on the next read.

Testing

  • All existing tests pass
  • Build compiles cleanly
  • Drift is detected by comparing the actual Helm release config against what the Terraform state expects

@dennismdejong
dennismdejong requested review from a team, iam404 and rigalGit as code owners July 27, 2026 20:09
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.

When the release fails for any reason do not update the state

1 participant