Description
Deploying a codebase with requireRoles on a project with no existing managed service account creates the SA, grants roles, then immediately calls createFunction. IAM SA creation is eventually consistent, so GCF rejects the brand new SA:
i functions: Creating managed service account firebase-fn-5873801311@<project>.iam.gserviceaccount.com...
i functions: Granting IAM roles to firebase-fn-5873801311@<project>.iam.gserviceaccount.com...
⚠ functions: Request to .../functions?functionId=... had HTTP Error: 404, Service account
projects/-/serviceAccounts/firebase-fn-5873801311@... was not found. ... verify that the caller
has been granted the 'iam.serviceAccounts.actAs' permission.
The SA does exist (visible in console immediately after). There's currently no mitigation on either side:
grantNewRoles creates the SA and returns without polling for visibility (src/deploy/functions/release/fabricator.ts:98-118), and applyPlan goes straight into function creates (fabricator.ts:210-212)
- the 404 is never retried:
DEFAULT_RETRY_CODES = [429, 409, 503] (src/deploy/functions/release/executor.ts:22), and createV2Function's catch only special-cases Cloud Run RESOURCE_EXHAUSTED before rethrowing as DeploymentError (fabricator.ts:557-571)
Steps to reproduce
- Project with no
firebase-fn-* SA, codebase using requireRoles
firebase deploy --only functions
- SA is created and roles granted, then every function create fails with the 404 above
Failing tests reproducing both facets (createFunction 404 never retried, getServiceAccount never polled after create) are up as a draft PR: #10858.
Is the intended fix to poll the SA for visibility after creation, to retry this specific 404 on the create path, or both? Terraform and gcloud both sleep-retry here, and a visibility poll alone may not be enough since GCF's own actAs check can lag behind IAM reads.
Description
Deploying a codebase with
requireRoleson a project with no existing managed service account creates the SA, grants roles, then immediately calls createFunction. IAM SA creation is eventually consistent, so GCF rejects the brand new SA:The SA does exist (visible in console immediately after). There's currently no mitigation on either side:
grantNewRolescreates the SA and returns without polling for visibility (src/deploy/functions/release/fabricator.ts:98-118), andapplyPlangoes straight into function creates (fabricator.ts:210-212)DEFAULT_RETRY_CODES = [429, 409, 503](src/deploy/functions/release/executor.ts:22), andcreateV2Function's catch only special-cases Cloud Run RESOURCE_EXHAUSTED before rethrowing as DeploymentError (fabricator.ts:557-571)Steps to reproduce
firebase-fn-*SA, codebase usingrequireRolesfirebase deploy --only functionsFailing tests reproducing both facets (createFunction 404 never retried, getServiceAccount never polled after create) are up as a draft PR: #10858.
Is the intended fix to poll the SA for visibility after creation, to retry this specific 404 on the create path, or both? Terraform and gcloud both sleep-retry here, and a visibility poll alone may not be enough since GCF's own actAs check can lag behind IAM reads.