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

Openstack instance: metadata is not removed #11239

Closed
michalmedvecky opened this issue Jan 17, 2017 · 3 comments · Fixed by #11252
Closed

Openstack instance: metadata is not removed #11239

michalmedvecky opened this issue Jan 17, 2017 · 3 comments · Fixed by #11252
Labels

Comments

@michalmedvecky
Copy link

Terraform does not remove metadata when you remove it from .tf file.

TLDR:

  1. create any new openstack_v2 instance with some_metadata = some_value
  2. modify your tf file so that some_metadata does not exist anymore and create another one (some_metadata2); terraform apply
  3. result: your instance now has metadata some_metadata and some_metadata2

Terraform Version

Terraform v0.8.4

Affected Resource(s)

  • openstack_compute_instance_v2

Terraform Configuration Files

create.tf:

provider "openstack" {
  alias = "mytenant"
  user_name = "mmedvecky"
  tenant_name = "mytenant"
  auth_url = "http://1.2.3.4:5000/"
}

resource "openstack_compute_instance_v2" "mmedvecky-test01" {
  provider = "openstack.mytenant"
  name = "mmedvecky-test01"
  image_id = "5a0bdb06-5dfe-4202-8f14-0de39156ee43"
  flavor_name = "m1.small"
  key_pair = "misko"
  availability_zone = "mz"
  security_groups = ["default"]

  metadata {
    test_metadata = "test"
  }

  network {
    name = "mytenantnetwork"
  }

}

modify.tf:

provider "openstack" {
  alias = "mytenant"
  user_name = "mmedvecky"
  tenant_name = "mytenant"
  auth_url = "http://1.2.3.4:5000/"
}

resource "openstack_compute_instance_v2" "mmedvecky-test01" {
  provider = "openstack.mytenant"
  name = "mmedvecky-test01"
  image_id = "5a0bdb06-5dfe-4202-8f14-0de39156ee43"
  flavor_name = "m1.small"
  key_pair = "misko"
  availability_zone = "mz"
  security_groups = ["default"]

  metadata {
    test_metadata2 = "test"
  }

  network {
    name = "mytenantnetwork"
  }

}

Expected Behavior

test_metadata should be removed

Actual Behavior

test_metadata still exists

Steps to Reproduce

  1. Copy create.tf to your terraform directory
  2. Run terraform apply - your VM will be created
  3. edit create.tf, modify test_metadata -> test_metadata2
  4. run terraform apply
ubuntu@deployer:~/iam-deployment/tftest$ terraform apply
openstack_compute_instance_v2.mmedvecky-test01: Refreshing state... (ID: 15d89d43-cb2a-4af9-a560-8adbe8b2f387)
openstack_compute_instance_v2.mmedvecky-test01: Modifying...
  metadata.test_metadata:  "test" => ""
  metadata.test_metadata2: "" => "test"
openstack_compute_instance_v2.mmedvecky-test01: Modifications complete

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate
  1. run terraform apply again:
ubuntu@deployer:~/iam-deployment/tftest$ terraform apply
openstack_compute_instance_v2.mmedvecky-test01: Refreshing state... (ID: 15d89d43-cb2a-4af9-a560-8adbe8b2f387)
openstack_compute_instance_v2.mmedvecky-test01: Modifying...
  metadata.%:             "2" => "1"
  metadata.test_metadata: "test" => ""
openstack_compute_instance_v2.mmedvecky-test01: Modifications complete

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

and again:

ubuntu@deployer:~/iam-deployment/tftest$ terraform apply
openstack_compute_instance_v2.mmedvecky-test01: Refreshing state... (ID: 15d89d43-cb2a-4af9-a560-8adbe8b2f387)
openstack_compute_instance_v2.mmedvecky-test01: Modifying...
  metadata.%:             "2" => "1"
  metadata.test_metadata: "test" => ""
openstack_compute_instance_v2.mmedvecky-test01: Modifications complete

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

The state of your infrastructure has been saved to the path
below. This state is required to modify and destroy your
infrastructure, so keep it safe. To inspect the complete state
use the `terraform show` command.

State path: terraform.tfstate

See, it always says modifications complete, but the old removed metadata still persists on the host.

@jtopjian
Copy link
Contributor

@michalmedvecky Thank you for the report!

#11252 should fix this problem :)

@michalmedvecky
Copy link
Author

Works for my test case! Thanks!

@ghost
Copy link

ghost commented Apr 17, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants