inlined.sa propagation cleanup - #10871
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds the FUNCTION_REGION environment variable to v2 functions to maintain parity with v1 behavior. It also refactors the deployment retry mechanism to use flexible RetryPredicate functions instead of numeric codes, enabling retries on specific 404 errors related to service accounts. Additionally, it introduces automatic cleanup of newly created service accounts on 100% deployment or role assignment failures. The feedback highlights a potential crash in the isServiceAccount404 predicate when calling JSON.stringify(err) on circular error structures, suggesting a safer try-catch fallback to String(err).
### Description Updates CHANGELOG.md to reference PR #10871. Refactors isServiceAccount404 in executor.ts to safely extract error text with String(err) fallback inside a try-catch block to prevent circular reference stringification errors. ### Scenarios Tested - Run mocha unit tests - Run npm run format
Fixes service account IAM propagation delays during Cloud Functions creation by adding a pluggable retry policy to executor task runs. Automatically deletes newly created managed service accounts if 100% of function deploys fail for a codebase. Fixes #10859 Fixes #10860 - Run unit tests: npx mocha src/deploy/functions/release/executor.spec.ts src/deploy/functions/release/fabricator.spec.ts src/deploy/functions/release/planner.spec.ts src/deploy/functions/prepare.spec.ts - Verified lint: npm run lint:changed-files N/A
Updates CHANGELOG.md to reference PR #10871. Refactors isServiceAccount404 in executor.ts to safely extract error text with String(err) fallback inside a try-catch block to prevent circular reference stringification errors. - Run mocha unit tests - Run npm run format
…ecutor ### Description Replaces unanchored substring search with word boundary regex checks in isServiceAccount404 to resolve CodeQL alert. ### Scenarios Tested - Run mocha tests - Verified formatting
5636c69 to
c1bf446
Compare
|
Note: The change to GEMINI.md is because it failed to follow the rule. When interrogated it said that's because it interpreted the rule to be about functions, not loops and suggested the change. |
|
Also, ignore the function region stuff; that was a bad diffbase |
…ount404 ### Description Concatenates err.message, err.original?.message, err.context?.body?.error?.message, and String(err) in isServiceAccount404 instead of short-circuiting via || to ensure nested error details are inspected. ### Scenarios Tested - Run mocha unit tests
* fix(functions): retry SA 404s and clean up SA on 100% deployment failure Fixes service account IAM propagation delays during Cloud Functions creation by adding a pluggable retry policy to executor task runs. Automatically deletes newly created managed service accounts if 100% of function deploys fail for a codebase. Fixes #10859 Fixes #10860 - Run unit tests: npx mocha src/deploy/functions/release/executor.spec.ts src/deploy/functions/release/fabricator.spec.ts src/deploy/functions/release/planner.spec.ts src/deploy/functions/prepare.spec.ts - Verified lint: npm run lint:changed-files N/A * fix(functions): address PR review comments for SA propagation retries Updates CHANGELOG.md to reference PR #10871. Refactors isServiceAccount404 in executor.ts to safely extract error text with String(err) fallback inside a try-catch block to prevent circular reference stringification errors. - Run mocha unit tests - Run npm run format * fix(functions): use word boundary regex for gserviceaccount.com in executor ### Description Replaces unanchored substring search with word boundary regex checks in isServiceAccount404 to resolve CodeQL alert. ### Scenarios Tested - Run mocha tests - Verified formatting * style(functions): format long string in executor.spec.ts to satisfy prettier * style(changelog): format CHANGELOG.md with prettier * style(changelog): reset CHANGELOG.md to single PR entry following release * style(changelog): prettier format single entry CHANGELOG.md * fix(functions): concatenate all error message sources in isServiceAccount404 ### Description Concatenates err.message, err.original?.message, err.context?.body?.error?.message, and String(err) in isServiceAccount404 instead of short-circuiting via || to ensure nested error details are inspected. ### Scenarios Tested - Run mocha unit tests
Fixes #10859 and #10860
To handle race conditions with SA propagation without polluting code everywhere, executor and throttler queue now accept retry predicates. Friendly predicate names are provided. I've opted to not have consts that are used repeatedly because isTransientError seems like a good thing to be able to read at the call site for what is retried.
To handle cleanup we've just extended the logic in fabricator.