juju / terraform-provider-juju

A Terraform provider for Juju
Apache License 2.0
19 stars 36 forks source link

Unable to create application #444

Open hemanthnakkina opened 5 months ago

hemanthnakkina commented 5 months ago

Description

Ran sunbeam on single node [1] and got an error in terraform plan that deploys openstack cloud [2]

The terraform logs shows the following error:

2024-04-03T08:07:58.194Z [INFO]  Starting apply for juju_application.traefik
2024-04-03T08:07:58.206Z [INFO]  Starting apply for juju_application.traefik-public
...
...
2024-04-03T08:07:59.148Z [ERROR] provider.terraform-provider-juju_v0.11.0: Response contains error diagnostic: tf_proto_version=6.4 tf_req_id=eb3b47d7-e50b-cc32-100a-d05292d8bd4a tf_resource_type=juju_application tf_rpc=ApplyResourceChange diagnostic_summary="Client Error" tf_provider_addr=registry.terraform.io/juju/juju diagnostic_detail="Unable to create application, got error: charm "ch:amd64/focal/traefik-k8s-164" already exists" diagnostic_severity=ERROR @caller=github.com/hashicorp/terraform-plugin-go@v0.22.1/tfprotov6/internal/diag/diagnostics.go:58 @module=sdk.proto timestamp=2024-04-03T08:07:59.148Z
2024-04-03T08:07:59.148Z [ERROR] vertex "juju_application.traefik" error: Client Error

There are 2 instances of traefik charm deployed with different app names. This is intermittent and happens rarely but seems like there is race either in terraform-juju-provider or juju.

terraform provider version used: 0.11.0 juju version used: 3.4/stable (3.4.1 at the time this bug is observed)

[1] https://microstack.run/docs/single-node [2] https://github.com/canonical/sunbeam-terraform

Urgency

Casually reporting

Terraform Juju Provider version

0.11.0

Terraform version

v1.3.7

Terraform Configuration(s)

No response

Reproduce / Test

Sunbeam on single node [1]

To simplify the usecase, you can take a plan with 2 instances of traefik and apply the plan traefik.tf.txt

Debug/Panic Output

No response

Notes & References

No response

hmlanigan commented 5 months ago

TF provider 0.11.0 is using a different deploy code path with juju >= 3.3 than juju < 3.3. This is most likely a juju bug, not terraform provider.

hemanthnakkina commented 5 months ago

Added a simple terraform plan with 2 traefik instances

gboutry commented 5 months ago

This already happened in terraform provider < 0.11

gboutry commented 4 months ago

Related to https://github.com/juju/terraform-provider-juju/pull/329