-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(functions): Set serviceAccount for Cloud Functions when custom service account is specified #9598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(functions): Set serviceAccount for Cloud Functions when custom service account is specified #9598
Changes from 5 commits
4bea578
203a9ea
14df88c
7692be0
af48d76
a28defb
cfb836f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,7 @@ | |
| source: Source; | ||
| sourceToken?: string; | ||
| environmentVariables: Record<string, string>; | ||
| serviceAccount?: string | null; | ||
|
|
||
| // Output only | ||
| build?: string; | ||
|
|
@@ -215,10 +216,10 @@ | |
| * @param type Type of deployment - create, update, or delete. | ||
| * @param err The error returned from the operation. | ||
| */ | ||
| function functionsOpLogReject(func: InputCloudFunction, type: string, err: any): void { | ||
| // Sniff for runtime validation errors and log a more user-friendly warning. | ||
| if (err?.message?.includes("Runtime validation errors")) { | ||
|
Check warning on line 221 in src/gcp/cloudfunctionsv2.ts
|
||
| const capturedMessage = captureRuntimeValidationError(err.message); | ||
| utils.logLabeledWarning("functions", capturedMessage + " for function " + func.name); | ||
| } | ||
| if (err?.message?.includes("maxScale may not exceed")) { | ||
|
|
@@ -467,16 +468,18 @@ | |
| "ingressSettings", | ||
| "timeoutSeconds", | ||
| ); | ||
| proto.convertIfPresent( | ||
| gcfFunction.serviceConfig, | ||
| endpoint, | ||
| "serviceAccountEmail", | ||
| "serviceAccount", | ||
| (from) => | ||
| !from | ||
| ? null | ||
| : proto.formatServiceAccount(from, endpoint.project, true /* removeTypePrefix */), | ||
| ); | ||
|
|
||
| if (Object.prototype.hasOwnProperty.call(endpoint, "serviceAccount")) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Can you leave a comment here on why we're not using |
||
| const serviceAccount = endpoint.serviceAccount; | ||
| if (!serviceAccount) { | ||
| gcfFunction.buildConfig.serviceAccount = null; | ||
| gcfFunction.serviceConfig.serviceAccountEmail = null; | ||
| } else { | ||
| const email = proto.formatServiceAccount(serviceAccount, endpoint.project, true); | ||
| gcfFunction.buildConfig.serviceAccount = `projects/${endpoint.project}/serviceAccounts/${email}`; | ||
| gcfFunction.serviceConfig.serviceAccountEmail = email; | ||
| } | ||
| } | ||
| // Memory must be set because the default value of GCF gen 2 is Megabytes and | ||
| // we use mebibytes | ||
| const mem = endpoint.availableMemoryMb || backend.DEFAULT_MEMORY; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran this through gemini and it also suggested some additional test cases: