错误 403:对于项目编号为 123456789 的消费者,服务 'cloudresourcemanager.googleapis.com' 的配额指标 '读取请求' 和限制 '每分钟每用户读取请求' 已超出配额。
Error 403: Quota exceeded for quota metric 'Read requests' and limit 'Read requests per minute per user' of service 'cloudresourcemanager.googleapis.com' for consumer 'project_number:123456789'.
ID: policy/gcp-resource-manager-quota-exceeded
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| GCP SDK 400.x | active | — | — | — |
| GCP SDK 410.x | active | — | — | — |
| GCP SDK 420.x | active | — | — | — |
根因分析
Cloud Resource Manager API 有每分钟每用户的读取请求配额(默认 60/分钟),自动化脚本或 CI/CD 流水线在短时间内发出过多 API 调用导致超出该配额。
English
The Cloud Resource Manager API has a per-user per-minute read request quota (default 60/min) that is being exceeded by automated scripts or CI/CD pipelines making too many API calls in a short period.
官方文档
https://cloud.google.com/resource-manager/docs/limits解决方案
-
在代码中实现带抖动的指数退避,以在达到配额限制时减慢请求速率。 示例(Python): import time import random def call_with_backoff(client, request, max_retries=5): for i in range(max_retries): try: return client.execute(request) except Exception as e: if 'Quota exceeded' in str(e): sleep_time = (2 ** i) + random.uniform(0, 1) time.sleep(sleep_time) else: raise raise Exception("Max retries exceeded") -
从 GCP 控制台请求增加 Cloud Resource Manager API 每分钟每用户读取请求的配额。这需要提交支持工单。 示例: 转到 GCP 控制台 > IAM 和管理 > 配额 > 选择 'Cloud Resource Manager API' > '每分钟每用户读取请求' > 编辑 > 增加限制。
-
将多个读取请求批处理到单个 API 调用中,使用 'getIamPolicy' 或 'testIamPermissions' 方法处理多个资源,从而减少请求数量。 示例: # 使用 list 方法并设置较大的 page size 以减少调用次数 request = cloudresourcemanager_v3.Projects().list(pageSize=100) while request: response = service.projects().list(body=request).execute() # 处理响应 request = service.projects().list_next(request, response)
无效尝试
常见但无效的做法:
-
Retrying immediately after failure
45% 失败
Simply retrying the request after a short delay may work temporarily but the quota will be exceeded again if the same rate of requests continues.
-
Creating a new service account
60% 失败
Creating a new service account and re-running the script will still hit the same per-user quota limit if the script makes requests at the same rate.
-
Disabling and re-enabling the API
80% 失败
Disabling and re-enabling the Cloud Resource Manager API does not reset the quota counter; the quota is based on per-user usage over time.