Skip to content

Fix #472: When the release fails for any reason do not update the state - #1857

Open
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/472-failed-release-state
Open

Fix #472: When the release fails for any reason do not update the state#1857
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:fix/472-failed-release-state

Conversation

@dennismdejong

Copy link
Copy Markdown

Description

Fixes #472. When a helm_release apply fails - whether due to chart download errors, template rendering errors, pod scheduling failures, or timeout - Terraform was still writing the failed configuration to state. On subsequent applies, Terraform detected no diff and did not retry the deployment.

Root Cause

Two issues:

  1. Read function: getRelease fetches the Helm release from the cluster. When an upgrade partially succeeds (new revision created with new values, but pods fail), release.Config contains the new values. The old code compared these with reflect.DeepEqual and set state.Values to the deployed YAML on mismatch. This meant the state would still reflect the desired values, preventing retry.

  2. setReleaseAttributes: This function sets computed attributes (Status, Metadata) from the release but never touched Set/SetSensitive/Values fields. After a failed Create partial-failure path (where err != nil && rel != nil), the state retained the desired values from the plan, causing no diff on the next plan.

Fix

  • Read function: Compare deployed values (release.Config) with state-computed desired values using JSON serialization. When they differ, clear Set, SetSensitive, SetList, and Values to null so Terraform detects drift.
  • setReleaseAttributes: When the release status is not deployed, or when the computed desired values differ from release.Config, clear the values fields in state. This catches both failed Creates and failed Updates during the Read cycle.

Testing

  • go build and go vet pass
  • All existing unit tests pass

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