【问题标题】:Fails with Health check error in GCP composer using terraform使用 terraform 在 GCP 作曲家中因运行状况检查错误而失败
【发布时间】:2020-04-02 04:14:27
【问题描述】:

我试图使用 terraform 在 GCP 中创建 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"}}

main.tf

    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-platform terraform google-cloud-composer terraform-provider-gcp


    【解决方案1】:

    我已经在我的 GCP cloudshell Terraform 二进制文件中测试了您当前的用户案例,到目前为止没有出现任何问题,Composer 环境已成功创建:

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

    我的一些担忧:

    您报告的问题可能与使用旧版运行状况检查有关,这些检查基本上已弃用并由 split health checks 取代:

    自 2019 年 9 月 15 日起,如果您使用的是旧版运行状况检查, 您的应用程序将继续运行并接收运行状况检查,但 您将无法部署应用程序的新版本。

    你没有指定任何关于你的 Terraform GCP provider 版本的信息部分,我想这个问题可以隐藏在那里,正如我在这个 Changelog 中看到的那样,split_health_checksgoogle_app_engine_application.feature_settings 中被启用,因为3.0.0-beta.1已发布。

    请随意添加更多见解,以支持您解决当前问题。

    【讨论】:

    • 我在使用 google provider 3.3.0 时遇到同样的错误,有什么提示吗?
    • 在默认的 Cloud Composer version 上构建 composer 时是否遇到同样的错误?
    • 通过gcloud 或 GCP 控制台构建 composer 环境,你得到了相同的结果吗?
    • 即使直接使用 gcloud 也会遇到同样的错误,请参阅 stackoverflow.com/questions/59428114/…
    • 希望该问题已根据提供的链接为您解决,正如@itroulli 在答案中所建议的那样。
    猜你喜欢
    • 2021-12-26
    • 2018-12-19
    • 2020-04-13
    • 1970-01-01
    • 2016-10-31
    • 2020-03-26
    • 2021-09-07
    • 2021-10-18
    • 1970-01-01
    相关资源
    最近更新 更多