Skip to content

container: set default timeout for google_container_node_pool to 2 hours#18250

Open
BBBmau wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
BBBmau:container-node-pool-2-hour-timeout
Open

container: set default timeout for google_container_node_pool to 2 hours#18250
BBBmau wants to merge 1 commit into
GoogleCloudPlatform:mainfrom
BBBmau:container-node-pool-2-hour-timeout

Conversation

@BBBmau

@BBBmau BBBmau commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Fixes hashicorp/terraform-provider-google#27427

when using the following config i found that although it wasn't working as expected on terraform apply, checking the state of the node_pool showed node replacement which occurred at 1hr15 minutes, exceeding the 1 hour default timeout that resources have.

terraform {
  required_version = ">= 1.6.0"

  required_providers {
    google = {
      source  = "hashicorp/google"
      version = "~> 7.37"
    }
    kubernetes = {
      source  = "hashicorp/kubernetes"
      version = "~> 2.31"
    }
  }
}

provider "google" {
  project = var.project_id
  region  = var.region
}

data "google_client_config" "default" {}

resource "google_container_cluster" "repro" {
  name     = "${var.name_prefix}-cluster"
  location = var.zone

  # Keep the default pool tiny and separate from the pool under test.
  remove_default_node_pool = false
  initial_node_count       = 1

  deletion_protection = false

  network    = "default"
  subnetwork = "default"

  release_channel {
    channel = "REGULAR"
  }
}

resource "google_container_node_pool" "repro" {
  count = var.create_test_pool ? 1 : 0

  name     = "${var.name_prefix}-pool"
  cluster  = google_container_cluster.repro.id
  location = var.zone

  node_count = var.node_count

  autoscaling {
    min_node_count = 1
    max_node_count = var.max_node_count
  }

  node_drain_config {
    respect_pdb_during_node_pool_deletion = false
  }

  management {
    auto_repair  = true
    auto_upgrade = true
  }

  timeouts {
    update = var.node_pool_update_timeout
  }

  node_config {
    machine_type = var.updated_machine_type ? var.updated_machine_type_value : var.machine_type

    oauth_scopes = [
      "https://www.googleapis.com/auth/cloud-platform"
    ]

    labels = {
      repro = "issue-27427"
    }
  }
}

provider "kubernetes" {
  host                   = "https://${google_container_cluster.repro.endpoint}"
  token                  = data.google_client_config.default.access_token
  cluster_ca_certificate = base64decode(google_container_cluster.repro.master_auth[0].cluster_ca_certificate)
}

resource "kubernetes_namespace" "repro" {
  count = var.deploy_pressure_workload ? 1 : 0

  metadata {
    name = "issue-27427"
  }
}

resource "kubernetes_pod_disruption_budget_v1" "pressure" {
  count = var.deploy_pressure_workload ? 1 : 0

  metadata {
    name      = "app-pdb"
    namespace = kubernetes_namespace.repro[0].metadata[0].name
  }

  spec {
    min_available = "1"

    selector {
      match_labels = {
        app = "stateful-pressure"
      }
    }
  }

  depends_on = [google_container_node_pool.repro]
}

resource "kubernetes_stateful_set_v1" "pressure" {
  count = var.deploy_pressure_workload ? 1 : 0

  metadata {
    name      = "stateful-pressure"
    namespace = kubernetes_namespace.repro[0].metadata[0].name
    labels = {
      app = "stateful-pressure"
    }
  }

  spec {
    service_name = "stateful-pressure"
    replicas     = var.pressure_replicas

    selector {
      match_labels = {
        app = "stateful-pressure"
      }
    }

    template {
      metadata {
        labels = {
          app = "stateful-pressure"
        }
      }

      spec {
        node_selector = {
          "cloud.google.com/gke-nodepool" = "${var.name_prefix}-pool"
        }

        termination_grace_period_seconds = 300

        container {
          name  = "burn"
          image = "busybox:1.36"

          command = ["/bin/sh", "-c", "trap : TERM INT; while true; do sleep 5; done"]

          resources {
            requests = {
              cpu    = var.cpu_request
              memory = "64Mi"
            }
            limits = {
              cpu    = var.cpu_limit
              memory = "128Mi"
            }
          }
        }
      }
    }
  }

  depends_on = [google_container_node_pool.repro, kubernetes_pod_disruption_budget_v1.pressure]
}

output "cluster_name" {
  value = google_container_cluster.repro.name
}

output "test_pool_name" {
  value = "${var.name_prefix}-pool"
}

output "zone" {
  value = var.zone
}

This should resolve the linked issue while also supporting timeout override since they are only supported on resources that have Timeouts set within schema.Resource

Release Note Template for Downstream PRs (will be copied)

See Write release notes for guidance.

container: increase default timeout to 2 hours for `google_container_node_pool`

@BBBmau BBBmau requested a review from zli82016 July 10, 2026 17:54
@modular-magician

Copy link
Copy Markdown
Collaborator

Hi there, I'm the Modular magician. I've detected the following information about your changes for commit f13e27e:

Diff report

Your PR generated the following diffs in downstream repositories:

Repository Diff Link Changes
terraform-google-conversion View Diff 1 file changed, 7 insertions(+)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

respect_pdb_during_node_pool_deletion not working

2 participants