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

Regression: terraform cannot create google_computer_instance_group_manager in other region than project #9344

Closed
bastiaanb opened this issue Oct 12, 2016 · 4 comments

Comments

@bastiaanb
Copy link

bastiaanb commented Oct 12, 2016

Terraform Version

0.7.1-0.7.5: tested with 0.7.0, 0.7.1, 0.7.2 and 0.7.5. Version 0.7.0 is OK, 0.7.1 and higher show regression.

Affected Resource(s)

  • google_compute_autoscaler
  • google_computer_instance_group_manager

The issue is with the google_computer_instance_group_manager, not the autoscaler that tries to target it. See comment below

Terraform Configuration Files

provider "google" {}

variable "zones" {
  default = ["europe-west1-d", "us-east1-b"]
}

  resource "google_compute_autoscaler" "nomad_client_scaler" {
  count = 2
  name = "${format("nomad-client-scaler-%d", count.index)}"
  zone = "${element(var.zones, count.index)}"

  target = "${element(google_compute_instance_group_manager.nomad_client_group.*.self_link, count.index)}"
  autoscaling_policy = {
    min_replicas = 1
    max_replicas = 2
    cooldown_period = 60
    cpu_utilization = {
      target = 0.75
    }
  }
}

resource "google_compute_instance_group_manager" "nomad_client_group" {
  count = 2
  name = "${format("nomad-client-group-%d", count.index)}"
  zone = "${element(var.zones, count.index)}"

  description = "Group consisting of Nomad client nodes"
  instance_template = "${google_compute_instance_template.nomad_client.self_link}"
  base_instance_name = "${format("client-%d", count.index)}"
}

resource "google_compute_instance_template" "nomad_client" {
  name = "client"
  description = "Template for Nomad client nodes"
  instance_description = "Nomad client node"
  machine_type = "f1-micro"
  tags = ["nomad", "client"]

  scheduling {
    automatic_restart = true
    on_host_maintenance = "MIGRATE"
    preemptible = false
  }

  disk {
    source_image = "coreos-stable-1122-2-0-v20160906"
    auto_delete = true
    boot = true
  }

  network_interface {
    network = "default"
    access_config {}
  }

  metadata {
  }
}

Debug Output

https://gist.github.com/bastiaanb/864db1bceb0682f5efd83498b44bb1d2
Contains stderr and stdout of 0.7.5 and stdout of 0.7.0 for comparison.

Panic Output

none

Expected Behavior

google_compute_autoscalers should have been created, with autoscaler #0 pointing to instance group #0 and autoscaler #1 to instance group #1, like done by version 0.7.0.

Actual Behavior

Both autoscaler instances have the first instance group as target, which coincidentally fails due to different zones.

Steps to Reproduce

  1. terraform apply

Important Factoids

No 'atypical' settings or accounts.

References

None

@bastiaanb
Copy link
Author

Debug output shows that one instance group manager is 'removed':

2016/10/12 23:06:32 [DEBUG] plugin: terraform: google-provider (internal) 2016/10/12 23:06:32 [WARN] Removing Instance Group Manager "nomad-client-group-1" because it's gone

This would explain why both autoscalers get the same instance group manager: the list contains only the first group, so the element() function wraps.

It looks like the resourceComputeInstanceGroupManagerRead() function assumes that all instance group managers are created in the region of the project, see

    region, err := getRegion(d, config)
...
    resource, err := getZonalResourceFromRegion(getInstanceGroupManager, region, config.clientCompute, project)

Introduced in commit da1cf0d

This assumption is wrong, as GCP does not limit projects to a single region and breaks for example global load balancer setups.

@bastiaanb bastiaanb changed the title Regression: terraform incorrectly computes google_compute_autoscaler.target link Regression: terraform cannot create google_computer_instance_group_manager in other region than project Oct 13, 2016
@zbjornson
Copy link

I think this is the same as #9126 (where it's not marked as a regression).

@stack72
Copy link
Contributor

stack72 commented Jan 30, 2017

Closed via #11294

@stack72 stack72 closed this as completed Jan 30, 2017
@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.
Projects
None yet
Development

No branches or pull requests

4 participants