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

Autoscaling signal has empty condition #15033

Closed
sigismund opened this issue Jul 3, 2023 · 8 comments · Fixed by GoogleCloudPlatform/magic-modules#8327
Closed

Autoscaling signal has empty condition #15033

sigismund opened this issue Jul 3, 2023 · 8 comments · Fixed by GoogleCloudPlatform/magic-modules#8327
Assignees
Labels
breaking-change persistent-bug Hard to diagnose or long lived bugs for which resolutions are more like feature work than bug work service/terraform
Milestone

Comments

@sigismund
Copy link

TL;DR

When using the following autoscaling signal, an empty condition is created, which causes a UI error This item contains one or more errors

 metric {
  name   = "compute.googleapis.com/instance/cpu/utilization"
  target = 0.75
  type   = "GAUGE"
}

Expected behavior

Expected Metrics signal to look like this:

image

Observed behavior

Instead, there is an empty condition that is causing a UI issue.

image

Terraform Configuration

resource "google_compute_autoscaler" "default" {
  provider = google-beta

  name   = "my-autoscaler"
  zone   = "us-central1-f"
  target = google_compute_instance_group_manager.default.id

  autoscaling_policy {
    max_replicas    = 5
    min_replicas    = 1
    cooldown_period = 60

    metric {
      name   = "compute.googleapis.com/instance/cpu/utilization"
      target = 0.75
      type   = "GAUGE"
    }
  }
}

resource "google_compute_instance_template" "default" {
  provider = google-beta

  name           = "my-instance-template"
  machine_type   = "e2-medium"
  can_ip_forward = false

  tags = ["foo", "bar"]

  disk {
    source_image = data.google_compute_image.debian_9.id
  }

  network_interface {
    network = "default"
  }

  metadata = {
    foo = "bar"
  }

  service_account {
    scopes = ["userinfo-email", "compute-ro", "storage-ro"]
  }
}

resource "google_compute_target_pool" "default" {
  provider = google-beta

  name = "my-target-pool"
}

resource "google_compute_instance_group_manager" "default" {
  provider = google-beta

  name = "my-igm"
  zone = "us-central1-f"

  version {
    instance_template = google_compute_instance_template.default.id
    name              = "primary"
  }

  target_pools       = [google_compute_target_pool.default.id]
  base_instance_name = "autoscaler-sample"
}

data "google_compute_image" "debian_9" {
  provider = google-beta

  family  = "debian-11"
  project = "debian-cloud"
}

provider "google-beta" {
  region = "us-central1"
  zone   = "us-central1-a"

}

Terraform Version

Terraform: v1.5.1

Google Provider: 4.50.0 & 4.64.0 (tested with 2 different versions)

Additional information

Terraform might be accounting for the aggregator field and adding the extra = that is causing the issue. If i click edit from the UI and turn on and off the aggregator the extra condition is removed and the issue is fixed.

image

@sigismund sigismund added the bug label Jul 3, 2023
@edwardmedia edwardmedia self-assigned this Jul 4, 2023
@edwardmedia
Copy link
Contributor

@sigismund have you tried adding filter in your config?

@sigismund
Copy link
Author

sigismund commented Jul 5, 2023

@edwardmedia By adding basic filter (filter = "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\"" ) I was able to bypass the error. So I guess the issue is related to the filter.

@edwardmedia
Copy link
Contributor

@sigismund I think you need to provide settings for filter if you are looking for its specific values. Does this make sense?

@sigismund
Copy link
Author

@edwardmedia Sorry, I think there was a misunderstanding. In our configuration, we are not using a filter. I was simply testing if adding a filter could bypass the error.

If you check the Terraform sample that I provided in the original description, you can see the configuration without a filter. Also, according to the documentation , the filter is an optional parameter for the google_compute_autoscaler resource. Therefore, the original configuration that I posted should not cause any issues.

@edwardmedia
Copy link
Contributor

edwardmedia commented Jul 6, 2023

I see what you mean. @sigismund. From its api doc, it seems the api would have provided the default for filter. Now I think we need to provide a default value then.

If not specified, the type defaults to gce_instance.

@c2thorn
Copy link
Collaborator

c2thorn commented Aug 17, 2023

@zli82016 is there an upgrade guide for this?

@zli82016
Copy link
Collaborator

Yeah, the guide is merged to the main branch. GoogleCloudPlatform/magic-modules#8648

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking-change persistent-bug Hard to diagnose or long lived bugs for which resolutions are more like feature work than bug work service/terraform
Projects
None yet
5 participants