Terraform v0.12.24
provider.helm v1.2.3
Terraform state is retained as it is if helm fails to update the release.
Terraform state is updated and hence running plan once again shows everything as up to date.
terraform applyfound in Chart.yaml, but missing in charts/ directory:@kishorv06 could you provide a trace of the two apply sequences so we can take a deeper look into this?
https://www.terraform.io/docs/internals/debugging.html
I'm facing the same issue! I created a trace that show's this problem happening (you can check each individual command by searching for the string pedgonca @ N103303 in /tmp/test_terraform).
A full test can be done like this:
$ kind create cluster
$ kind get kubeconfig > kind.yaml
main.tf
resource "helm_release" "mysqldb" {
name = "mysqldb"
chart = "stable/mysql"
}
providers.tf
provider "helm" {
version = "~> 1.2.2"
kubernetes {
config_path = "/tmp/test_terraform/kind.yaml"
}
}
# pedgonca @ N103303 in /tmp/test_terraform [21:46:32]
$ terraform apply
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# helm_release.mysqldb will be created
+ resource "helm_release" "mysqldb" {
+ atomic = false
+ chart = "stable/mysql"
+ cleanup_on_fail = false
+ create_namespace = false
+ dependency_update = false
+ disable_crd_hooks = false
+ disable_openapi_validation = false
+ disable_webhooks = false
+ force_update = false
+ id = (known after apply)
+ lint = false
+ max_history = 0
+ metadata = (known after apply)
+ name = "mysqldb"
+ namespace = "default"
+ recreate_pods = false
+ render_subchart_notes = true
+ replace = false
+ reset_values = false
+ reuse_values = false
+ skip_crds = false
+ status = "deployed"
+ timeout = 300
+ verify = false
+ version = "1.6.6"
+ wait = true
}
Plan: 1 to add, 0 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
helm_release.mysqldb: Creating...
helm_release.mysqldb: Still creating... [10s elapsed]
helm_release.mysqldb: Creation complete after 14s [id=mysqldb]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
# pedgonca @ N103303 in /tmp/test_terraform [21:47:06]
$ sed -i.bak 's#stable/mysql#stable/FOOBARmysql#' main.tf
# pedgonca @ N103303 in /tmp/test_terraform [21:47:29]
$ terraform apply
helm_release.mysqldb: Refreshing state... [id=mysqldb]
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
# helm_release.mysqldb will be updated in-place
~ resource "helm_release" "mysqldb" {
atomic = false
~ chart = "stable/mysql" -> "stable/FOOBARmysql"
cleanup_on_fail = false
create_namespace = false
dependency_update = false
disable_crd_hooks = false
disable_openapi_validation = false
disable_webhooks = false
force_update = false
id = "mysqldb"
lint = false
max_history = 0
metadata = [
{
chart = "mysql"
name = "mysqldb"
namespace = "default"
revision = 1
values = "null"
version = "1.6.6"
},
]
name = "mysqldb"
namespace = "default"
recreate_pods = false
render_subchart_notes = true
replace = false
reset_values = false
reuse_values = false
skip_crds = false
status = "deployed"
timeout = 300
verify = false
version = "1.6.6"
wait = true
}
Plan: 0 to add, 1 to change, 0 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
helm_release.mysqldb: Modifying... [id=mysqldb]
Error: failed to download "stable/FOOBARmysql" (hint: running `helm repo update` may help)
on main.tf line 1, in resource "helm_release" "mysqldb":
1: resource "helm_release" "mysqldb" {
# pedgonca @ N103303 in /tmp/test_terraform [21:47:41] C:1
$ terraform apply
helm_release.mysqldb: Refreshing state... [id=mysqldb]
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
# pedgonca @ N103303 in /tmp/test_terraform [21:47:53]
As seen in the above execution, a failed terrraform apply in for an helm chart, will still save the state of the helm chart has updated, even tho the apply failed - when running the apply a second time, it just says the state is up to date.
I think there are already two PRs, which would fix this issue:
https://github.com/hashicorp/terraform-provider-helm/pull/512
https://github.com/hashicorp/terraform-provider-helm/pull/516
@mcuadros any word on either of these two options proposed in these PRs?
Is this a duplicate of #472?
Most helpful comment
I'm facing the same issue! I created a trace that show's this problem happening (you can check each individual command by searching for the string
pedgonca @ N103303 in /tmp/test_terraform).A full test can be done like this:
Create a local k8s cluster - I used kind
Initial terraform config
main.tf
providers.tf
Replicate the issue
Summary
As seen in the above execution, a failed
terrraform applyin for an helm chart, will still save the state of the helm chart has updated, even tho the apply failed - when running the apply a second time, it just says the state is up to date.