Fix #472: When the release fails for any reason do not update the state - #1857
Open
dennismdejong wants to merge 1 commit into
Open
Fix #472: When the release fails for any reason do not update the state#1857dennismdejong wants to merge 1 commit into
dennismdejong wants to merge 1 commit into
Conversation
…ct failed release state drift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #472. When a
helm_releaseapply 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:
Read function:
getReleasefetches the Helm release from the cluster. When an upgrade partially succeeds (new revision created with new values, but pods fail),release.Configcontains the new values. The old code compared these withreflect.DeepEqualand setstate.Valuesto the deployed YAML on mismatch. This meant the state would still reflect the desired values, preventing retry.setReleaseAttributes: This function sets computed attributes (Status, Metadata) from the release but never touched
Set/SetSensitive/Valuesfields. After a failed Create partial-failure path (whereerr != nil && rel != nil), the state retained the desired values from the plan, causing no diff on the next plan.Fix
release.Config) with state-computed desired values using JSON serialization. When they differ, clearSet,SetSensitive,SetList, andValuesto null so Terraform detects drift.deployed, or when the computed desired values differ fromrelease.Config, clear the values fields in state. This catches both failed Creates and failed Updates during the Read cycle.Testing
go buildandgo vetpass