Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Application,Machine,Model and Offer from state if it was removed manually #205

Merged
merged 1 commit into from
May 10, 2023

Conversation

amandahla
Copy link
Contributor

Description

This PR does the same as what was done for the Integration resource in the #192 PR. If the resource is removed manually, terraform plan fails with "no integrations exist in specified model". This PR changes the behavior to remove it from the state instead.

Type of change

Please mark if proceeds.

  • New resource (a new resource in the schema)
  • Changed resource (changes in an existing resource)
  • Logic changes in resources (the API interaction with Juju has been changed)
  • Test changes (one or several tests have been changed)
  • [X ] Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Other (describe)

Environment

  • Juju controller version: 2.9.42
  • Terraform version: 1.4.4

QA steps

Manual QA steps should be done to test this PR.

The same that was reported in issue #186

Additional notes

It might be worth doing this for all the resources and also creating a specific error for that instead of checking the error message.

@juanmanuel-tirado
Copy link
Contributor

You're right, we have to keep removing entities from the state if removed outside the plan. Thanks for the PR. I don't know if you have tested this manually but this hits a potential bug regarding the error check in applications. You can see that by running:

provider "juju" {

}

resource "juju_model" "test" {
  name = "test"
}

resource "juju_application" "tiny" {
  model = juju_model.test.name
  name  = "test"
  charm {
    name = "tiny-bash"
  }
}
juju remove-application -m test test
terraform apply
juju_model.test: Refreshing state... [id=2d82550b-990f-4d0b-8745-201bb2e28258]
juju_application.tiny: Refreshing state... [id=test:test]
╷
│ Error: Plugin did not respond
│ 
│   with juju_application.tiny,
│   on plan.tf line 18, in resource "juju_application" "tiny":
│   18: resource "juju_application" "tiny" {
│ 
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may
│ contain more details.
╵
I will give a +1 to this PR because I have spotted the problem and this code is not the cause. I will address that in other PR. In any case, please run/provide manual QA addressing the changes.

Thanks again for the PR. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants