Skip to content

fix: Address "inconsistent result after apply" error by moving metadata recalc - #1713

Merged
jaylonmcshan19-x merged 2 commits into
hashicorp:mainfrom
mkilchhofer:bugfix/1664_inconsistent_result
Nov 6, 2025
Merged

fix: Address "inconsistent result after apply" error by moving metadata recalc#1713
jaylonmcshan19-x merged 2 commits into
hashicorp:mainfrom
mkilchhofer:bugfix/1664_inconsistent_result

Conversation

@mkilchhofer

@mkilchhofer mkilchhofer commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Rollback Plan

Simply revert the commit, there are no schema changes.

Changes to Security Controls

None

Description

It seems that you check for metadata recompute too early. The version of the state and the plan matches already and thus the helper function func recomputeMetadata(plan HelmReleaseModel, state *HelmReleaseModel) bool { } is not able to resolve the version update of the chart in all cases we evauluate in the lines below.

By moving the whole block to the end, it seems that the plan is updated for several version update cases.

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
$ kind get clusters
testing

$ kubectl get nodes
NAME                         STATUS   ROLES           AGE   VERSION
testing-control-plane        Ready    control-plane   14d   v1.34.0

$ make testacc
...
ok  	github.com/hashicorp/terraform-provider-helm/helm	389.272s

Plus manual testing:

Before:

$ terraform plan
helm_release.my_local_chart: Refreshing state... [id=my-local-chart]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # helm_release.my_local_chart will be updated in-place
  ~ resource "helm_release" "my_local_chart" {
        id                         = "my-local-chart"
        name                       = "my-local-chart"
      ~ version                    = "1.10.16" -> "1.10.17"
        # (26 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

After:

$ TF_REATTACH_PROVIDERS='{"registry.terraform.io/hashicorp/helm":{"Protocol":"grpc","ProtocolVersion":6,"Pid":60272,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/8q/8b5t1wjn0sggk1vrzb82t7tw0000gn/T/plugin1683805268"}}}' terraform plan
helm_release.my_local_chart: Refreshing state... [id=my-local-chart]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # helm_release.my_local_chart will be updated in-place
  ~ resource "helm_release" "my_local_chart" {
      ~ id                         = "my-local-chart" -> (known after apply)
      ~ metadata                   = {
          + app_version    = (known after apply)
          ~ chart          = "my-local-chart" -> (known after apply)
          ~ first_deployed = 1761168691 -> (known after apply)
          ~ last_deployed  = 1761175638 -> (known after apply)
          ~ name           = "my-local-chart" -> (known after apply)
          ~ namespace      = "testing" -> (known after apply)
          + notes          = (known after apply)
          ~ revision       = 16 -> (known after apply)
          ~ values         = jsonencode({}) -> (known after apply)
          ~ version        = "1.10.16" -> (known after apply)
        } -> (known after apply)
        name                       = "my-local-chart"
      + take_ownership             = false
      + upgrade_install            = false
      ~ version                    = "1.10.16" -> "1.10.17"
        # (25 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Release Note

Release note for CHANGELOG:

Address "inconsistent result after apply" error by moving recomputeMetadata() function

References

Fixes #1664
Fixes #1692

Related to:

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

@mkilchhofer mkilchhofer changed the title fix: Recompute metadata at the end of the diff function fix: Address "inconsistent result after apply" error by moving metadata recalc Oct 22, 2025
@mkilchhofer
mkilchhofer marked this pull request as ready for review October 23, 2025 06:25
@mkilchhofer
mkilchhofer requested a review from a team as a code owner October 23, 2025 06:25
@mkilchhofer

Copy link
Copy Markdown
Contributor Author

friendly reminder @jrhouston @BBBmau :)

@mkilchhofer

Copy link
Copy Markdown
Contributor Author

Also ping @JaylonmcShan03 since you migrated the provider from SDKv2 to plugin framework :)

@jaylonmcshan19-x

Copy link
Copy Markdown
Contributor

Hi @mkilchhofer thank you for the contribution! I will check it out first thing tomorrow morning :)

@jaylonmcshan19-x

jaylonmcshan19-x commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

Hi @mkilchhofer just checked out your PR and everything looks good! One last request, can you please add a change log entry.

@mkilchhofer
mkilchhofer force-pushed the bugfix/1664_inconsistent_result branch from 568a5d4 to f4c6e70 Compare November 5, 2025 16:00
@mkilchhofer

Copy link
Copy Markdown
Contributor Author

Hi @mkilchhofer just checked out your PR and everything looks good! One last request, can you please add a change log entry.

Hi @jaylonmcshan19-x Thanks for your review. I rebased on latest main and added the requested changelog entry as well 🙏

@jaylonmcshan19-x
jaylonmcshan19-x merged commit b6a090b into hashicorp:main Nov 6, 2025
18 checks passed
mitchell-thompson-CS pushed a commit to toast-dog/kubernetes-terraform that referenced this pull request Mar 29, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [helm](https://registry.terraform.io/providers/hashicorp/helm) ([source](https://github.com/hashicorp/terraform-provider-helm)) | required_provider | major | `~> 2.17` → `~> 3.0` |

---

### Release Notes

<details>
<summary>hashicorp/terraform-provider-helm (helm)</summary>

### [`v3.1.1`](https://github.com/hashicorp/terraform-provider-helm/blob/HEAD/CHANGELOG.md#311-Nov-17-2025)

[Compare Source](hashicorp/terraform-provider-helm@v3.1.0...v3.1.1)

BUG FIXES:

- `resource/helm_release`: Fix "inconsistent result after apply" error by moving recomputeMetadata function call \[[GH-1713](hashicorp/terraform-provider-helm#1713)]

### [`v3.1.0`](https://github.com/hashicorp/terraform-provider-helm/blob/HEAD/CHANGELOG.md#310-Oct-27-2025)

[Compare Source](hashicorp/terraform-provider-helm@v3.0.2...v3.1.0)

FEATURES:

- Add `qps` field to Helm provider configuration \[[GH-1668](hashicorp/terraform-provider-helm#1668)]
- Add `resources` attribute to manifest experimental feature \[[GH-1693](hashicorp/terraform-provider-helm#1693)]
- `helm_template`: Add `set_wo` write-only attribute \[[GH-1703](hashicorp/terraform-provider-helm#1703)]
- `helm_release`: Add support for the `take_ownership` field \[[GH-1680](hashicorp/terraform-provider-helm#1680)]

ENHANCEMENT:

- Introduce the `timeouts` field to the helm\_release resource and helm\_template data source, enabling configurable operation timeouts for create, read, update, and delete actions. \[[GH-1702](hashicorp/terraform-provider-helm#1702)]

BUG FIXES:

- Port missing field `upgrade_install` \[[GH-1675](hashicorp/terraform-provider-helm#1675)]

### [`v3.0.2`](https://github.com/hashicorp/terraform-provider-helm/blob/HEAD/CHANGELOG.md#302-Jun-23-2025)

[Compare Source](hashicorp/terraform-provider-helm@v3.0.1...v3.0.2)

This is a patch release that fixes a number of bugs discovered in the v3.x.x release.

BUG FIXES:

- `helm_release`: Fix description field causing inconsistent plan \[[GH-1648](hashicorp/terraform-provider-helm#1648)]
- `helm_release`: Fix plan error when `devel = false` is set and `version` is provided \[[GH-1656](hashicorp/terraform-provider-helm#1656)]
- `helm_release`: Fix postrender being run when binaryPath is nil \[[GH-1649](hashicorp/terraform-provider-helm#1649)]
- `helm_release`: Fix shallow clone bug causing nested sensitive values to be redacted in the k8s API \[[GH-1644](hashicorp/terraform-provider-helm#1644)]
- `provider`: Fix namespace override logic in Kubernetes client initialization \[[GH-1650](hashicorp/terraform-provider-helm#1650)]
- `provider`: Restore support for the `KUBE_PROXY_URL` environment variable \[[GH-1655](hashicorp/terraform-provider-helm#1655)]

### [`v3.0.1`](https://github.com/hashicorp/terraform-provider-helm/blob/HEAD/CHANGELOG.md#301-Jun-18-2025)

[Compare Source](hashicorp/terraform-provider-helm@v3.0.0...v3.0.1)

This is a hotfix release.

HOTFIX:

- `helm_release`: Fix state upgrader code to use correct type for "values" attribute. \[[GH-1638](hashicorp/terraform-provider-helm#1638)]

### [`v3.0.0`](https://github.com/hashicorp/terraform-provider-helm/blob/HEAD/CHANGELOG.md#300-Jun-18-2025)

[Compare Source](hashicorp/terraform-provider-helm@v2.17.0...v3.0.0)

This release migrates ports the provider project from `terraform-plugin-sdk/v2` to `terraform-plugin-framework` \[[GH-1379](hashicorp/terraform-provider-helm#1379)]

Please refer to the [migration guide](./docs/guides/v3-upgrade-guide.md).

BREAKING CHANGES:

- **Blocks to Nested Objects**: Blocks like `kubernetes`, `registry`, and `experiments` are now represented as nested objects.
- **List Syntax for Nested Attributes**: Attributes like `set`, `set_list`, and `set_sensitive` in `helm_release` and `helm_template` are now lists of nested objects instead of blocks
- The new framework code uses [Terraform Plugin Protocol Version 6](https://developer.hashicorp.com/terraform/plugin/terraform-plugin-protocol#protocol-version-6) which is compatible with Terraform versions 1.0 and above. Users of earlier versions of Terraform can continue to use the Helm provider by pinning their configuration to the 2.x version.

FEATURES:

- Add `"literal"` as a supported `type` for the `set` block \[[GH-1615](hashicorp/terraform-provider-helm#1615)]

- `helm_release`: Add support for ResourceIdentity. \[[GH-1625](hashicorp/terraform-provider-helm#1625)]

- `helm_release`: Add `set_wo` write-only attribute \[[GH-1592](hashicorp/terraform-provider-helm#1592)]

ENHANCEMENT:

- `helm_release`: Add `UpgradeState` logic to support migration from SDKv2 to Plugin Framework \[[GH-1633](hashicorp/terraform-provider-helm#1633)]
- update helm dependency to v3.17.2 \[[GH-1608](hashicorp/terraform-provider-helm#1608)]

BUG FIXES:

- `helm_release`: Fix namespace behaviour for dependency charts in non-default namespaces \[[GH-1583](hashicorp/terraform-provider-helm#1583)]

- change `set.value` && `set_list.value` to optional instead of required \[[GH-1572](hashicorp/terraform-provider-helm#1572)]

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4zNS4xIiwidXBkYXRlZEluVmVyIjoiNDMuMzUuMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsicmVub3ZhdGUiXX0=-->

Reviewed-on: https://git.thompson-manor.org/toast-dog/kubernetes-terraform/pulls/1
Co-authored-by: Renovate Bot <renovate@toastdog.net>
Co-committed-by: Renovate Bot <renovate@toastdog.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

2 participants