Skip to content

fix(functions): retry service account quota errors and stop reporting them as permission errors - #11580

Open
IzaakGough wants to merge 4 commits into
mainfrom
@invertase/fix-sa-create-quota-retry
Open

IzaakGough wants to merge 4 commits into
mainfrom
@invertase/fix-sa-create-quota-retry

Conversation

@IzaakGough

@IzaakGough IzaakGough commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • The retry waits about 3 minutes in total (5s doubling to a 60s cap), so it outlasts a one-minute quota window.
  • Only the per-minute quota is retried. Other 429s, such as the total service account cap, fail straight away.

Tested with unit tests and a live deploy of 5 firestore-bigquery-export kit 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.

… 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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@IzaakGough
IzaakGough marked this pull request as ready for review November 24, 2026 10:10

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

permissions error when deploying multiple functions at the same time with firebase deploy

1 participant