排查环境创建问题

Cloud Composer 1 | Cloud Composer 2

本页面针对创建 Cloud Composer 环境时可能遇到的问题提供了问题排查信息。

如需了解与更新和升级环境相关的问题排查信息,请参阅排查环境更新和升级问题

在创建 Cloud Composer 环境时,导致大多数问题的原因如下:

  • 服务账号权限问题

  • 防火墙、DNS 或路由信息不正确

  • 与网络相关的问题。例如,无效的 VPC 配置、IP 地址冲突或网络 IP 范围过窄

  • 与配额相关的问题

  • 不兼容的组织政策

权限不足,无法创建环境

如果 Cloud Composer 由于您的账号权限不足而无法创建环境,它将输出以下错误消息:

ERROR: (gcloud.composer.environments.create) PERMISSION_DENIED: The caller
does not have permission

ERROR: (gcloud.composer.environments.create) PERMISSION_DENIED: User not
authorized to act as service account <service-account-name>.
The user must be granted iam.serviceAccounts.actAs permission, included in
Owner, Editor, Service Account User role. See https://cloud.google.com/iam/docs
/understanding-service-accounts for additional details.

解决方案:按照访问权限控制中所述,为您的帐号和环境的服务帐号分配角色。

  • 在 Cloud Composer 2 中,确保 Cloud Composer Service Agent 服务帐号 (service-PROJECT_NUMBER@cloudcomposer-accounts.iam.gserviceaccount.com) 已分配 Cloud Composer v2 API Service Agent Extension 角色。

  • 确保 Google APIs Service Agent (PROJECT_NUMBER@cloudservices.gserviceaccount.com) 已分配 Editor 角色。

  • 在共享 VPC 配置中,按照配置共享 VPC 说明执行操作。

环境的服务账号权限不足

创建 Cloud Composer 环境时,您需要指定一个服务帐号来运行该环境的 GKE 集群节点。如果此服务帐号没有足够的权限来执行请求的操作,则 Cloud Composer 会输出以下错误:

Errors in: [Web server]; Error messages:
  Creation of airflow web server version failed. This may be an intermittent
  issue of the App Engine service. You may retry the operation later.
{"ResourceType":"appengine.v1.version","ResourceErrorCode":"504","ResourceError
Message":"Your deployment has failed to become healthy in the allotted time
and therefore was rolled back. If you believe this was an error, try adjusting
the 'app_start_timeout_sec' setting in the 'readiness_check' section."}

解决方案:按照访问权限控制中所述,为您的帐号和环境的服务帐号分配角色。

关于服务账号中缺少 IAM 角色的警告

如果环境创建失败,Cloud Composer 会在发生错误后生成以下警告消息:The issue may be caused by missing IAM roles in the following Service Accounts ...

此警告消息会突出显示导致错误的可能原因。 Cloud Composer 会检查项目中服务帐号的所需角色,如果这些角色不存在,则生成此警告消息。

解决方案:检查警告消息中提及的服务帐号是否具有所需的角色。如需详细了解 Cloud Composer 中的角色和权限,请参阅访问权限控制

在某些情况下,您可以忽略此警告。Cloud Composer 不会检查分配给角色的各项权限。例如,如果您使用自定义 IAM 角色,则警告消息中提及的服务帐号可能已具有所有必需的权限。在这种情况下,您可以忽略此警告。

为环境选择的 VPC 网络不存在

您可以在创建 Cloud Composer 环境时指定 VPC 网络和子网。如果您未指定 VPC 网络,则 Cloud Composer 服务会为环境的区域和可用区选择 default VPC 和 default 子网。

如果指定的 VPC 网络和子网不存在,则 Cloud Composer 会输出以下错误:

Errors in: [GKE cluster]; Error messages:
        {"ResourceType":"gcp-types/container-v1:projects.locations.clusters","R
        esourceErrorCode":"400","ResourceErrorMessage":{"code":400,"message":"P
        roject \"<your composer project>\" has no network named \"non-existing-
        vpc\".","status":"INVALID_ARGUMENT","statusMessage":"Bad
        Request","requestPath":"https://container.googleapis.com/
        v1/projects/<your composer
        project>/locations/<zone>/clusters","httpMethod":"POST"}}

解决方案

  • 在 Cloud Composer 2 中,您可以创建使用 Private Service Connect 的环境,而不是 VPC 网络。
  • 在创建环境之前,请确保新环境的 VPC 网络和子网存在。

网络配置不正确

创建 Cloud Composer 环境需要进行正确的网络或 DNS 配置。请按照以下说明配置与 Google API 和服务的连接:

如果您在共享 VPC 模式下配置 Cloud Composer 环境,还需要按照这些共享 VPC 说明操作。

Cloud Composer 环境为集群节点使用子网,并为 Pod 和 Service 使用 IP 地址范围。为了确保与这些 IP 地址范围和其他 IP 地址范围的通信,请按照以下说明配置防火墙规则:

您还可以在 Activity 中检查选定 GCE NetworkingSubnetwork 配置类别中的任何日志条目,以查看在创建环境期间是否报告了任何错误。

在大规模网络中创建环境时遇到配额问题

在大规模网络中创建 Cloud Composer 环境时,您可能会遇到以下配额限制:

  • 已达到每个 VPC 网络的 VPC 对等互连数上限。
  • 已达到主要和次要子网 IP 范围数上限。
  • 已达到对等互连组中用于内部 TCP/UDP 负载平衡的转发规则数上限。

解决方案

不兼容的组织政策

您必须适当配置以下政策,才能成功创建 Cloud Composer 环境。

Organization Policy Cloud Composer 1 Cloud Composer 2
compute.disableSerialPortLogging 对于 1.13.0 之前的版本已停用;对于其他版本为任意值 必须停用
compute.requireOsLogin 必须停用 允许任何值
compute.vmCanIpForward 如果未配置 VPC 原生模式(使用别名 IP),则必须允许(该政策对于 Cloud Composer 拥有的 GKE 集群是必需的) 允许任何值
compute.vmExternalIpAccess 对于公共 IP 环境,必须允许 对于公共 IP 环境,必须允许
compute.restrictVpcPeering 无法强制执行 无法强制执行
compute.disablePrivateServiceConnectCreationForConsumers 允许任何值 如果使用 Private Service Connect,则无法禁止“SERVICE_PRODUCERS”

如需了解详情,请参阅已知问题页面和组织政策限制条件

限制在组织或项目中使用的服务

组织或项目管理员可以使用 gcp.restrictServiceUsage 组织政策限制条件来限制可在其项目中使用的 Google 服务。

使用此组织政策时,请务必允许 Cloud Composer 所需的所有服务

400 错误消息:部署 Airflow 网络服务器失败。

此错误可能是由于 IP 范围重叠而未能创建专用 IP 环境的 GKE 集群而导致的。

解决方案:检查日志中是否存在有关环境集群的任何故障,并根据相应的 GKE 错误消息解决问题。

Cloud Build 无法构建环境映像

如果 Cloud Build 服务帐号 (PROJECT_NUMBER@cloudbuild.gserviceaccount.com) 在项目中没有 Cloud Build Service Account (roles/cloudbuild.builds.builder) 角色,则尝试创建或更新环境可能会失败,并显示与权限相关的错误。

例如,您可能会在 Cloud Build 日志中看到 denied: Permission "artifactregistry.repositories.uploadArtifacts" denied 消息,后跟 ERROR: failed to push because we ran out of retries

如需解决此问题,请确保 Cloud Build 服务帐号具有 Cloud Build Service Account 角色。

后续步骤