首页 > 解决方案 > 使用 terraform 在 GCP 作曲家中因运行状况检查错误而失败

问题描述

我试图在 GCP 中使用 terraform 创建一个 Cloud Composer。我使用的是 terraform 版本 Terraform v0.12.5。但我无法使用 terraform 启动实例。

我收到以下错误

Error: Error waiting to create Environment: Error waiting for Creating Environment: Error code 3, message: Http error status code: 400
Http error message: BAD REQUEST
Additional errors:
    {"ResourceType":"appengine.v1.version","ResourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"Legacy health checks are no longer supported for the App Engine Flexible environment. Please remove the 'health_check' section from your app.yaml and configure updated health checks. For instructions on migrating to split health checks see https://cloud.google.com/appengine/docs/flexible/java/migrating-to-split-health-checks","status":"INVALID_ARGUMENT","details":[],"statusMessage":"Bad Request","requestPath":"https://appengine.googleapis.com/v1/apps/qabc39fc336994cc4-tp/services/default/versions","httpMethod":"POST"}}

主文件

    resource "google_composer_environment" "sample-composer" {
      provider= google-beta
      project = "${var.project_id}"
      name    = "${var.google_composer_environment_name}"
      region  = "${var.region}"
      config {
        node_count = "${var.composer_node_count}"

        node_config {
          zone         = "${var.zone}"
          disk_size_gb = "${var.disk_size_gb}"
          machine_type = "${var.composer_machine_type}"
          network      = google_compute_network.xxx-network.self_link
          subnetwork = google_compute_subnetwork.xxx-subnetwork.self_link
        }
        software_config {
          env_variables = {
              AIRFLOW_CONN_SAMPLEMEDIA_FTP_CONNECTION = "ftp://${var.ftp_user}:${var.ftp_password}@${var.ftp_host}"
        }
          image_version  = "${var.composer_airflow_version}"
          python_version = "${var.composer_python_version}"
        }
      }
    }

resource "google_compute_network" "sample-network" {
  name    = "composer-xxx-network"
  project = "${var.project_id}"
  auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "sample-subnetwork" {
  name          = "composer-xxx-subnetwork"
  project       = "${var.project_id}"
  ip_cidr_range = "10.2.0.0/16"
  region        = "${var.region}"
  network       = google_compute_network.xxx-network.self_link
}

变量.tf

# Machine specific information for creating Instance in GCP

variable "project_id" {
  description = "The name of GCP project"
  default = "sample-test"
}

variable "google_composer_environment_name" {
  description = "The name of the instance"
  default = "sample-analytics-dev"
}

variable "region" {
  description = "The name of GCP region"
  default = "europe-west1"
}

variable "composer_node_count" {
  description = "The number of node count"
  default = "3"
}

variable "zone" {
  description = "The zone in which instance to be launched"
  default = "europe-west1-c"
}

variable "disk_size_gb" {
  description = "The machine size in GB"
  default = "100"
}

variable "composer_machine_type" {
  description = "The type of machine to be launched in GCP"
  default = "n1-standard-1"
}

# Environmental Variables

variable "ftp_user" {
  description = "Environmental variables for FTP user"
  default = "test"
}

variable "ftp_password" {
  description = "Environmental variables for FTP password"
  default = "4444erf"
}

variable "ftp_host" {
  description = "Environmental variables for FTP host"
  default = "sample.logs.llnw.net"
}

# Versions for Cloud Composer, Aiflow and Python

variable "composer_airflow_version" {
  description = "The composer and airflow versions to launch instance in GCP"
  default = "composer-1.7.2-airflow-1.10.2"
}

variable "composer_python_version" {
  description = "The version of python"
  default = "3"
}

# Network information

variable "composer_network_name" {
  description = "Environmental variables for FTP user"
  default = "composer-xxx-network"
}

variable "composer_subnetwork_name" {
  description = "Environmental variables for FTP user"
  default = "composer-xxx-subnetwork"
}        

在 GCP 平台上创建 Composer 没有任何问题。使用 terraform 创建时,需要进行健康检查。

标签: google-cloud-platformterraformgoogle-cloud-composerterraform-provider-gcp

解决方案


I've tested your current user case within my GCP cloudshell Terraform binary and so far no issue occurred, Composer environment has been successfully created:

$ terraform -v                                                                                                                                                                                          
Terraform v0.12.9
+ provider.google v3.1.0
+ provider.google-beta v3.1.0

A few concerns from my side:

The issue you've reported might be relevant to the usage of legacy health checks, which are essentially deprecated and replaced by split health checks:

As of September 15, 2019, if you're using the legacy health checks, your application will continue to run and receive health checks but you won't be able to deploy new versions of your application.

You've not specified any info part about your Terraform GCP provider version and I suppose that issue can be hidden there, as I've seen in this Changelog that split_health_checks are enabled in google_app_engine_application.feature_settings since 3.0.0-beta.1 has been released.

Feel free to add some more insights in order to support you resolving the current issue.


推荐阅读