Add a no-op message to check_quota if it fails.

MG_DOCKER_CODES_PIPER_ORIGIN_REV_ID: 792654121
This commit is contained in:
Rayan Dasoriya
2025-08-08 09:32:08 -07:00
committed by Copybara-Service
parent 58dab0b1bb
commit 44390cbd99
2 changed files with 24 additions and 6 deletions
@@ -494,9 +494,12 @@ def get_quota(project_id: str, region: str, resource_id: str) -> int:
f" --service={service_endpoint} --consumer=projects/{project_id}"
f" --filter='{service_endpoint}/{resource_id}' --format=json"
)
process = subprocess.run(
command, shell=True, capture_output=True, text=True, check=True
)
try:
process = subprocess.run(
command, shell=True, capture_output=True, text=True, check=True
)
except subprocess.CalledProcessError:
return -2
if process.returncode == 0:
quota_data = json.loads(process.stdout)
else:
@@ -662,6 +665,12 @@ def check_quota(
" to check quota in a region or request additional quota for "
"your project."
)
if quota == -2:
print(
"This is a no-op for now. Please check the quota manually to verify if"
" you have enough quota for your use case."
)
return
if quota == -1:
raise ValueError(
f"Quota not found for: {resource_id} in {region}."
@@ -494,9 +494,12 @@ def get_quota(project_id: str, region: str, resource_id: str) -> int:
f" --service={service_endpoint} --consumer=projects/{project_id}"
f" --filter='{service_endpoint}/{resource_id}' --format=json"
)
process = subprocess.run(
command, shell=True, capture_output=True, text=True, check=True
)
try:
process = subprocess.run(
command, shell=True, capture_output=True, text=True, check=True
)
except subprocess.CalledProcessError:
return -2
if process.returncode == 0:
quota_data = json.loads(process.stdout)
else:
@@ -662,6 +665,12 @@ def check_quota(
" to check quota in a region or request additional quota for "
"your project."
)
if quota == -2:
print(
"This is a no-op for now. Please check the quota manually to verify if"
" you have enough quota for your use case."
)
return
if quota == -1:
raise ValueError(
f"Quota not found for: {resource_id} in {region}."