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

TypeSet count (.#) not being removed when d.Set(nil) is used w/ 0.12 SDK #20506

Closed
rileykarson opened this issue Feb 27, 2019 · 2 comments · Fixed by #20522
Closed

TypeSet count (.#) not being removed when d.Set(nil) is used w/ 0.12 SDK #20506

rileykarson opened this issue Feb 27, 2019 · 2 comments · Fixed by #20522
Milestone

Comments

@rileykarson
Copy link
Contributor

Terraform Version

Running a Google provider acceptance test with 
github.com/hashicorp/terraform v0.12.0-alpha4.0.20190226230829-c2f653cf1a35 vendored.

master is in this state.

Terraform Configuration Files

resource "google_compute_disk" "test1" {
  name = "%s"
  zone = "us-central1-a"
  size = 10
}

resource "google_compute_instance" "test" {
  name         = "%s"
  machine_type = "f1-micro"
  zone         = "us-central1-a"

  lifecycle {
    ignore_changes = [
      "attached_disk",
    ]
  }

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
    }
  }

  network_interface {
    network = "default"
  }
}

resource "google_compute_attached_disk" "test" {
  disk     = "${google_compute_disk.test1.self_link}"
  instance = "${google_compute_instance.test.self_link}"
}

Followed by

resource "google_compute_disk" "test1" {
  name = "%s"
  zone = "us-central1-a"
  size = 10
}

resource "google_compute_instance" "test" {
  name         = "%s"
  machine_type = "f1-micro"
  zone         = "us-central1-a"

  lifecycle {
    ignore_changes = [
      "attached_disk",
    ]
  }

  boot_disk {
    initialize_params {
      image = "debian-cloud/debian-9"
    }
  }

  network_interface {
    network = "default"
  }
}

Expected Behavior

Terraform should see an empty list of users for the disk as the attachment was removed.

Actual Behavior

STATE:

google_compute_disk.test1:
  ID = tf-test-disk-4936674271243668487
  provider = provider.google
  creation_timestamp = 2019-02-27T02:15:50.880-08:00
  description = 
  image = 
  label_fingerprint = 42WmSpB8rSM=
  last_attach_timestamp = 2019-02-27T02:16:19.543-08:00
  last_detach_timestamp = 2019-02-27T02:16:31.576-08:00
  name = tf-test-disk-4936674271243668487
  project = hc-terraform-testing
  self_link = https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/zones/us-central1-a/disks/tf-test-disk-4936674271243668487
  size = 10
  snapshot = 
  source_image_id = 
  source_snapshot_id = 
  type = pd-standard
  users.# = 1
  zone = us-central1-a

leading to

 Error: errors during apply: Unknown user "" of disk "https://www.googleapis.com/compute/v1/projects/hc-terraform-testing/zones/us-central1-a/disks/tf-test-disk-4936674271243668487"

because of https://github.com/terraform-providers/terraform-provider-google/blob/master/google/resource_compute_disk.go#L752

Steps to Reproduce

make testacc TEST=./google TESTARGS='-run=TestAccComputeAttachedDisk_basic'
@apparentlymart apparentlymart added this to the v0.12.0 milestone Feb 28, 2019
@jbardin
Copy link
Member

jbardin commented Feb 28, 2019

Hi @rileykarson,

Thanks for the detail here. This test has some interesting interactions that I haven't completely sorted out. I'm just gong to bullet a few things here to investigate:

  • The attached_disk attribute is not computed, but it is set during Read, which is chained from Create. Since it's not computed, plus the values aren't planned at all, it cannot be reliably set during apply.
  • The .# count attribute is used in the source, which is an implementation detail that shouldn't appear in provider code.
  • A number of other attributes are set during apply which weren't set in the plan.

These aren't necessarily related to the users set getting the empty value, but may be related to other oddities you see with these resource.

@jbardin jbardin closed this as completed Feb 28, 2019
@jbardin jbardin reopened this Feb 28, 2019
rileykarson added a commit to hashicorp/terraform-provider-google-beta that referenced this issue Mar 1, 2019
We aren't ready to release a `0.12` SDK based build because of these issues:

• hashicorp/terraform#20505hashicorp/terraform#20507hashicorp/terraform#20506hashicorp/terraform#20504
rileykarson added a commit to hashicorp/terraform-provider-google that referenced this issue Mar 1, 2019
We aren't ready to release a `0.12` SDK based build because of these issues:

• hashicorp/terraform#20505hashicorp/terraform#20507hashicorp/terraform#20506hashicorp/terraform#20504
@ghost
Copy link

ghost commented Mar 29, 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 Mar 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants