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

google_compute_region_per_instance_config fails with empty preserved_state #7365

Open
riptl opened this issue Sep 28, 2020 · 1 comment
Open

Comments

@riptl
Copy link

riptl commented Sep 28, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.13.3
+ provider registry.terraform.io/hashicorp/google v3.40.0
+ provider registry.terraform.io/hashicorp/google-beta v3.40.0
+ provider registry.terraform.io/hashicorp/random v2.3.0
+ provider registry.terraform.io/hashicorp/template v2.1.2

Affected Resource(s)

  • google_compute_region_per_instance_config (google-beta v3.40.0)

Terraform Configuration Files

resource "google_compute_region_per_instance_config" "alertmanager" {
  provider = google-beta

  count = var.replicas

  project = var.project_id
  name    = "alertmanager-${var.region}-${count.index}"
  region  = var.region

  region_instance_group_manager = google_compute_region_instance_group_manager.alertmanager.name

  minimal_action = "REPLACE"

  preserved_state {} # NOTICE THIS IS EMPTY
}

Debug Output

When applying this, the provider makes two calls:

  • Creating the instance /compute/beta/projects/xxx/regions/us-central1/instanceGroupManagers/alertmanager-us-central1/createInstances
  • Listing per instance configs /compute/beta/projects/xxx/regions/us-central1/instanceGroupManagers/alertmanager-us-central1/listPerInstanceConfigs

https://gist.github.com/terorie/4502ebca06aa73d5eb316b49498d0767

Expected Behavior

Apply completes.

Actual Behavior

Error: Provider produced inconsistent result after apply

Steps to Reproduce

  1. Create a managed instance group
  2. Define a per-instance config without preserved_state
  3. terraform apply

Important Factoids

The per-instance config returned by /listPerInstanceConfigs is an empty object {} if preserved_state is empty.

This behavior is wanted in a rare circumstance when instances in a MIG are supposed to have stable names but are still stateless.

Apply works when specifying some data inside preserved_state, such as a dummy metadata value, presumably because the preserved_state is not an empty object.

This leads me to believe that the provider handles empty objects erroneously.

References

@ghost ghost added the bug label Sep 28, 2020
@slevenick
Copy link
Collaborator

Odd... Does the instance group actually have an instance named after the empty-state per instance config? The result from the API being empty seems to indicate that the instance group does not do anything with the per-instance-config.

I don't see a way to handle this in the provider given how the API does not include the instance in the result of listPerInstanceConfigs

@edwardmedia edwardmedia removed their assignment Mar 25, 2021
modular-magician added a commit to modular-magician/terraform-provider-google that referenced this issue Mar 7, 2023
…duling. (hashicorp#7365)

* Move testing to handwritten

* Move testing to handwritten

* Fix lint

* Fix typo

* Add remove step and update documentation

* Add remove step and update documentation

* Fix comparing string to nil

* Add field to handwritten defs

* rebase on main & resolve conflicts

* Fix doc formatting

* Add maintenance interval to Instance resource

* Add maintenance interval to Instance resource

* Add maintenance interval to Instance resource

* Change function names to valid

* Fix type mismatch

* Fix type mismatch

* Fix function name

Signed-off-by: Modular Magician <magic-modules@google.com>
modular-magician added a commit that referenced this issue Mar 7, 2023
…duling. (#7365) (#13932)

* Move testing to handwritten

* Move testing to handwritten

* Fix lint

* Fix typo

* Add remove step and update documentation

* Add remove step and update documentation

* Fix comparing string to nil

* Add field to handwritten defs

* rebase on main & resolve conflicts

* Fix doc formatting

* Add maintenance interval to Instance resource

* Add maintenance interval to Instance resource

* Add maintenance interval to Instance resource

* Change function names to valid

* Fix type mismatch

* Fix type mismatch

* Fix function name

Signed-off-by: Modular Magician <magic-modules@google.com>
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-managed labels Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants