GCP Quota Analysis - Quick Reference Guide
Python Script for Monitoring Quota Usage
Section titled “Python Script for Monitoring Quota Usage”The script is located at - https://gitlab.com/gitlab-com/gl-infra/db-migration/-/blob/master/bin/gcs_quota_checker.py
The script pulls current quota usage vs allocation per project and region.
Requirements
Section titled “Requirements”pip install google-cloud-compute tabulateBasic Usage
Section titled “Basic Usage”# Check staging project in us-east1python gcp_quota_checker.py --project gitlab-staging-1 --region us-east1
# Check all regionspython gcp_quota_checker.py --project gitlab-staging-1 --all-regions
# Filter SSD quotas only (recommended for your case)python gcp_quota_checker.py --project gitlab-staging-1 --region us-east1 --filter SSD
# Lower threshold to see more quotaspython gcp_quota_checker.py --project gitlab-staging-1 --region us-east1 --threshold 50
# Export to CSV for analysispython gcp_quota_checker.py --project gitlab-staging-1 --all-regions --output quotas.csvSpecific Commands for Your Use Case
Section titled “Specific Commands for Your Use Case”1. Check SSD Quotas Before Upgrade
Section titled “1. Check SSD Quotas Before Upgrade”# Python versionpython gcp_quota_checker.py \ --project gitlab-staging-1 \ --region us-east1 \ --filter "SSD,DISK" \ --threshold 70 \ --output ssd_quotas_pre_upgrade.csv2. Check N2D Family Quotas
Section titled “2. Check N2D Family Quotas”# Python versionpython gcp_quota_checker.py \ --project gitlab-staging-1 \ --region us-east1 \ --filter "N2D,VM_FAMILY"3. Comprehensive Pre-Upgrade Check
Section titled “3. Comprehensive Pre-Upgrade Check”# Check all critical quotas across all regionspython gcp_quota_checker.py \ --project gitlab-staging-1 \ --all-regions \ --threshold 60 \ --output pre_upgrade_audit.csv \ --show-allUnderstanding the Output
Section titled “Understanding the Output”Key Metrics to Watch
Section titled “Key Metrics to Watch”For PostgreSQL/Patroni Upgrades:
LOCAL_SSD_TOTAL_GB- Total local SSD across all VMsLOCAL_SSD_TOTAL_GB_PER_VM_FAMILY- Per VM family (N2D)CPUS- CPU quota for new instancesPERSISTENT_DISK_SSD_GB- Persistent SSD disksIN_USE_ADDRESSES- Internal IP addressesINSTANCES- Total VM instances
Example Output
Section titled “Example Output”⚠️ High Usage Quotas (>= 70%)================================================================================Project Region Metric Usage Limit Usage%gitlab-staging-1 us-east1 LOCAL_SSD_TOTAL_GB 3600.00 3744.00 96.2%gitlab-staging-1 us-east1 LOCAL_SSD_TOTAL_GB_N2D 3600.00 3744.00 96.2%gitlab-staging-1 us-east1 CPUS 140.00 200.00 70.0%
Summary: Total quotas checked: 156 High usage quotas (>= 70%): 3 Critical (>= 90%): 2 Warning (80-90%): 0
⚠️ SSD-related quotas at risk: 2 • gitlab-staging-1/us-east1: LOCAL_SSD_TOTAL_GB = 96.2% • gitlab-staging-1/us-east1: LOCAL_SSD_TOTAL_GB_N2D = 96.2%Requesting Quota Increases
Section titled “Requesting Quota Increases”If quotas are near limits:
1. Via gcloud CLI
Section titled “1. Via gcloud CLI”# Request quota increase for LOCAL_SSD_TOTAL_GBgcloud compute project-info describe \ --project=gitlab-staging-1 \ --format="value(quotas.filter(metric:LOCAL_SSD_TOTAL_GB))"
# Submit increase request (need to use Console for this)# Go to: https://console.cloud.google.com/iam-admin/quotas2. Via Console
Section titled “2. Via Console”- Go to: https://console.cloud.google.com/iam-admin/quotas
- Filter by region: us-east1
- Filter by metric: LOCAL_SSD_TOTAL_GB
- Click “EDIT QUOTAS”
- Request new limit (suggest: +50% above current)
3. Calculate Required Quota
Section titled “3. Calculate Required Quota”# For Patroni v17 upgrade (4 nodes):# Current per node: 900 GB local SSD (estimated)# New nodes needed: 4# Required: 4 × 900 = 3,600 GB# Plus existing: 3,600 GB# Total needed: 7,200 GB (current limit: 3,744 GB)
# Request at least: 8,000 GB to have headroomPre-Upgrade Checklist
Section titled “Pre-Upgrade Checklist”Run these commands before upgrade:
# 1. Full quota audit./gcp_quota_check.sh -p gitlab-staging-1 -a -o pre_upgrade_full.csv
# 2. SSD-specific check./gcp_quota_check.sh -p gitlab-staging-1 -r us-east1 -f SSD -t 60
# 3. CPU check./gcp_quota_check.sh -p gitlab-staging-1 -r us-east1 -f CPUS -t 60
# 4. Disk check./gcp_quota_check.sh -p gitlab-staging-1 -r us-east1 -f DISK -t 60
# 5. IP address check./gcp_quota_check.sh -p gitlab-staging-1 -r us-east1 -f ADDRESS -t 60Automating Quota Monitoring
Section titled “Automating Quota Monitoring”Cron Job for Daily Checks
Section titled “Cron Job for Daily Checks”# Add to crontab0 8 * * * /path/to/gcp_quota_check.sh -p gitlab-staging-1 -t 80 -o /var/log/quotas/daily_$(date +\%Y\%m\%d).csvAlert on High Usage
Section titled “Alert on High Usage”#!/bin/bashOUTPUT=$(/path/to/gcp_quota_check.sh -p gitlab-staging-1 -r us-east1 -t 80)EXIT_CODE=$?
if [[ $EXIT_CODE -ne 0 ]]; thenfiTroubleshooting
Section titled “Troubleshooting””Permission Denied” Error
Section titled “”Permission Denied” Error”# Ensure you have compute.regions.get permissiongcloud projects get-iam-policy gitlab-staging-1 \ --flatten="bindings[].members" \ --filter="bindings.members:user:$(gcloud config get-value account)"”Project Not Found” Error
Section titled “”Project Not Found” Error”# List accessible projectsgcloud projects list
# Set active projectgcloud config set project gitlab-staging-1Quotas Not Updating
Section titled “Quotas Not Updating”# Clear gcloud cachegcloud compute regions describe us-east1 \ --project=gitlab-staging-1 \ --format=json > /dev/null
# Wait 1-2 minutes and retryAdditional Resources
Section titled “Additional Resources”Last Updated: January 2026 Maintained By: Database Team Version: 1.0.0