-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Event function source warning #10407
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
Changes from all commits
42e515f
67797d4
be02ebd
cef854f
ce2ddd4
de54c6a
5555438
70bcd03
abc06a7
09529c8
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 |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import * as backend from "./backend"; | ||
| import { serviceForEndpoint } from "./services"; | ||
| import * as utils from "../../utils"; | ||
|
|
||
| /** | ||
| * Ensures the trigger regions are set and correct | ||
|
|
@@ -16,4 +17,22 @@ export async function ensureTriggerRegions(want: backend.Backend): Promise<void> | |
| regionLookups.push(serviceForEndpoint(ep).ensureTriggerRegion(ep)); | ||
| } | ||
| await Promise.all(regionLookups); | ||
|
|
||
| // Warn if an event function defaults to or is assigned to us-central1 but its trigger is elsewhere, | ||
| // to avoid unnecessary cross-region network hops. We ignore nam5 since it covers us-central1. | ||
| for (const ep of backend.allEndpoints(want)) { | ||
| if ( | ||
| ep.region === "us-central1" && | ||
| backend.isEventTriggered(ep) && | ||
| ep.eventTrigger?.region && | ||
| ep.eventTrigger.region !== "us-central1" && | ||
| ep.eventTrigger.region !== "nam5" | ||
| ) { | ||
| utils.logLabeledWarning( | ||
| "functions", | ||
| `Function ${ep.id} located in us-central1 uses a trigger located in ${ep.eventTrigger.region}. ` + | ||
| `To avoid unnecessary cross-region network hops, you should explicitly assign this function to ${ep.eventTrigger.region}.`, | ||
| ); | ||
|
Comment on lines
+31
to
+35
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. The warning message suggests explicitly assigning the function to the trigger's region. However, for multi-region triggers (e.g., const triggerRegion = ep.eventTrigger.region;
const suggestion = triggerRegion.includes("-") ? triggerRegion : `a region within ${triggerRegion}`;
utils.logLabeledWarning(
"functions",
`Function ${ep.id} located in us-central1 uses a trigger located in ${triggerRegion}. ` +
`To avoid unnecessary cross-region network hops, you should explicitly assign this function to ${suggestion}.`,
); |
||
| } | ||
| } | ||
| } | ||
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.
The cross-region trigger validation should also exclude the
usmulti-region when the function is inus-central1. Similar tonam5for Firestore, theusmulti-region for Cloud Storage includesus-central1. Deploying a function inus-central1to handle events from ausbucket does not constitute a cross-region hop, and flagging it would create false positives for many standard Storage-triggered functions.