Repository navigation
fix(functions): retry service account quota errors and stop reporting them as permission errors - #11580
fix(functions): retry service account quota errors and stop reporting them as permission errors#11580IzaakGough wants to merge 4 commits into
Conversation
… them as permission errors Deploying several codebases with declarative security creates one managed service account per codebase. Hitting IAM's per-minute creation quota was reported as a missing permission. createServiceAccount now backs off on 429 for about 3 minutes, and grantNewRoles only shows the permissions message for a 403.
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where functions deploys with declarative security fail with a misleading permissions error when the IAM service account creation quota is reached. It introduces automatic retries with backoff (up to 6 retries, 5s to 60s delay) on 429 (RESOURCE_EXHAUSTED) quota errors during service account creation. Additionally, it updates the error handling in the fabricator to propagate the actual error message when service account creation or role assignment fails with a status code other than 403 (Permission Denied). Comprehensive unit tests have been added to verify these retry behaviors and error reporting paths. I have no feedback to provide as there are no review comments.
…he deploy path Move the retry out of iam.createServiceAccount so App Hosting, App Testing and hosting:github init keep their old behaviour, skip 429s that will not reset within a minute, and warn before waiting.
Fixes #11576.
Deploying many function codebases that use declarative security could fail with "you do not have permissions necessary to create the service account", even when the user had that permission. The real cause was IAM's per-minute limit on creating service accounts.
This retries service account creation during functions deploys when that limit is hit, with a warning while it waits, and shows the permissions message only for a real permission error.
Tested with unit tests and a live deploy of 5
firestore-bigquery-exportkit instances with the create quota temporarily lowered to 3 per minute: 15.37.0 failed with the permissions error, and this branch retried for about 80 seconds and deployed.