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_autoscaler update error #18332

Comments

@natedogith1
Copy link

natedogith1 commented Jun 5, 2024

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 a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Terraform Version & Provider Version(s)

Terraform v1.3.9
on linux_amd64

  • provider registry.terraform.io/hashicorp/google v4.84.0
  • provider registry.terraform.io/hashicorp/google-beta v4.84.0

Affected Resource(s)

google_compute_autoscaler

Terraform Configuration

resource "google_compute_autoscaler" "default" {
  provider    = google-beta
  project     = var.project_id
  name        = format("scal-%s",var.name)
  description = "Terraform-managed."
  zone        = var.zone
  target      = google_compute_instance_group_manager.default.id

  autoscaling_policy {
    max_replicas    = 10
    min_replicas    = 2
    cooldown_period = 900
    mode            = "ON"

    cpu_utilization {
      target = 0.99
    }
  }
  lifecycle {
    ignore_changes        = [ autoscaling_policy ]
  }
}


resource "google_compute_instance_group_manager" "default" {
  provider           = google-beta
  project            = var.project_id
  zone               = var.zone
  name               = format("mig-%s",var.name)
  description        = "Terraform-managed."
  base_instance_name = format("mig-%s",var.name)
  target_pools       = []
  wait_for_instances = false
  wait_for_instances_status = "STABLE"
  named_port {
    name = "https-443"
    port = 443
  }
  named_port {
    name = "https-8443"
    port = 8443
  }
  version {
    instance_template = var.default_version.instance_template
    name              = var.default_version.name
  }
  lifecycle {
    create_before_destroy = true
    ignore_changes        = [ version, update_policy, auto_healing_policies, ]
  }

  timeouts {
    create = "5m"
    update = "5m"
    delete = "15m"
  }
}

Debug Output

Terraform will perform the following actions:
  # google_compute_autoscaler.default will be updated in-place
  ~ resource "google_compute_autoscaler" "default" {
      + description        = "Terraform-managed."
        id                 = <content removed>
        name               = <content removed>
        # (5 unchanged attributes hidden)
        # (1 unchanged block hidden)
    }
╷
│ Error: Error waiting for Updating Autoscaler: Required field 'resource.autoscalingPolicy.maxNumReplicas' not specified
│ 
│ 
│   with google_compute_autoscaler.default[0],
│   on main.tf line 37, in resource "google_compute_autoscaler" "default":
│   37: resource "google_compute_autoscaler" "default" {
│ 
╵

Expected Behavior

Apply perform successfully

Actual Behavior

Apply fails with message "Required field 'resource.autoscalingPolicy.maxNumReplicas' not specified"

Steps to reproduce

  1. terraform apply
  2. Change min and max number of instances in GCP console to 0. (this also happens to clear the autoscaler description)
  3. terraform apply

Important Factoids

life_cycle is set to ignore autoscaling_policy changes. I have not tested if setting the min and max replica numbers to 0 in the terraform directly also causes this problem.

References

No response

b/345321691

@natedogith1 natedogith1 added the bug label Jun 5, 2024
@github-actions github-actions bot added forward/review In review; remove label to forward service/compute-autoscaler labels Jun 5, 2024
@ggtisc ggtisc self-assigned this Jun 6, 2024
@ggtisc
Copy link
Collaborator

ggtisc commented Jun 6, 2024

Confirmed issue!

As user explains when max_replicas and min_replicas values are equal to 0 terraform returns the next error message:

│ Error: Error waiting for Updating Autoscaler: Required field 'resource.autoscalingPolicy.maxNumReplicas' not specified
│ 
│   with google_compute_autoscaler.default[0],
│   on main.tf line 37, in resource "google_compute_autoscaler" "default":
│   37: resource "google_compute_autoscaler" "default" {

This could be an inconsistency, since both terraform registry and Google Cloud documentation is not specified that the value cannot be 0

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 Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.