-
Notifications
You must be signed in to change notification settings - Fork 1k
Cloud Run Functions data model #8767
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: master
Are you sure you want to change the base?
Changes from all commits
7ef4f67
4e61dbe
3d43507
ec92c97
2ae9410
cd0d894
eb95e4d
05120c7
6744e91
a41f634
f3ba1b2
50c0806
0cb1545
6ce821e
3f906e7
7847b16
33efe3f
ca83ac3
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 |
---|---|---|
|
@@ -300,7 +300,7 @@ | |
serviceAccount?: string | null; | ||
} | ||
|
||
export type FunctionsPlatform = "gcfv1" | "gcfv2"; | ||
export type FunctionsPlatform = "gcfv1" | "gcfv2" | "run"; | ||
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. While the |
||
export const AllFunctionsPlatforms: FunctionsPlatform[] = ["gcfv1", "gcfv2"]; | ||
|
||
export type Triggered = | ||
|
@@ -521,7 +521,7 @@ | |
await loadExistingBackend(context); | ||
} | ||
// loadExisting guarantees the validity of existingBackend and unreachableRegions | ||
return context.existingBackend!; | ||
} | ||
|
||
async function loadExistingBackend(ctx: Context): Promise<void> { | ||
|
@@ -534,6 +534,7 @@ | |
ctx.unreachableRegions = { | ||
gcfV1: [], | ||
gcfV2: [], | ||
run: [], | ||
}; | ||
const gcfV1Results = await gcf.listAllFunctions(ctx.projectId); | ||
for (const apiFunction of gcfV1Results.functions) { | ||
|
@@ -554,8 +555,8 @@ | |
ctx.existingBackend.endpoints[endpoint.region][endpoint.id] = endpoint; | ||
} | ||
ctx.unreachableRegions.gcfV2 = gcfV2Results.unreachable; | ||
} catch (err: any) { | ||
if (err.status === 404 && err.message?.toLowerCase().includes("method not found")) { | ||
Check warning on line 559 in src/deploy/functions/backend.ts
|
||
return; // customer has preview enabled without allowlist set | ||
} | ||
throw err; | ||
|
@@ -623,6 +624,15 @@ | |
"\nCloud Functions in these regions won't be deleted.", | ||
); | ||
} | ||
|
||
if (context.unreachableRegions?.run.length) { | ||
utils.logLabeledWarning( | ||
"functions", | ||
"The following Cloud Run regions are currently unreachable:\n" + | ||
context.unreachableRegions.run.join("\n") + | ||
"\nCloud Run services in these regions won't be deleted.", | ||
); | ||
} | ||
} | ||
|
||
/** A helper utility for flattening all endpoints in a backend since typing is a bit wonky. */ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -157,10 +157,11 @@ export async function prepare( | |||||
let resource: string; | ||||||
if (endpoint.platform === "gcfv1") { | ||||||
resource = `projects/${endpoint.project}/locations/${endpoint.region}/functions/${endpoint.id}`; | ||||||
} else if (endpoint.platform === "gcfv2") { | ||||||
} else if (endpoint.platform === "gcfv2" || endpoint.platform === "run") { | ||||||
// N.B. If GCF starts allowing v1's allowable characters in IDs they're | ||||||
// going to need to have a transform to create a service ID (which has a | ||||||
// more restrictive character set). We'll need to reimplement that here. | ||||||
// BUG BUG BUG. This has happened and we need to fix it. | ||||||
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. This comment indicates a known issue where the function ID to service ID conversion is not happening. It's marked as a
Suggested change
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. IMO the severity of this comment is accurate. This is a WIP and a BUG should be resolved before releasing to the public whereas a TODO can be ignored for years. |
||||||
resource = `projects/${endpoint.project}/locations/${endpoint.region}/services/${endpoint.id}`; | ||||||
} else { | ||||||
assertExhaustive(endpoint.platform); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -359,6 +359,10 @@ export async function updateEndpointSecret( | |||||||||
operationResourceName: op.name, | ||||||||||
}); | ||||||||||
return gcfV2.endpointFromFunction(cfn); | ||||||||||
} else if (endpoint.platform === "run") { | ||||||||||
// This may be tricky because the image has been deleted. How does this work | ||||||||||
// with GCF? | ||||||||||
throw new FirebaseError("Updating Cloud Run functions is not yet implemented."); | ||||||||||
Comment on lines
+363
to
+365
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. This error message is not very informative. Consider adding more context to the error message to help users understand why updating Cloud Run functions is not yet implemented.
Suggested change
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. Bad suggestion |
||||||||||
} else { | ||||||||||
assertExhaustive(endpoint.platform); | ||||||||||
} | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { expect } from "chai"; | ||
import * as k8s from "./k8s"; | ||
|
||
describe("megabytes", () => { | ||
enum Bytes { | ||
KB = 1e3, | ||
MB = 1e6, | ||
GB = 1e9, | ||
KiB = 1 << 10, | ||
MiB = 1 << 20, | ||
GiB = 1 << 30, | ||
} | ||
|
||
it("Should handle decimal SI units", () => { | ||
expect(k8s.mebibytes("1000k")).to.equal((1000 * Bytes.KB) / Bytes.MiB); | ||
expect(k8s.mebibytes("1.5M")).to.equal((1.5 * Bytes.MB) / Bytes.MiB); | ||
expect(k8s.mebibytes("1G")).to.equal(Bytes.GB / Bytes.MiB); | ||
}); | ||
|
||
it("Should handle binary SI units", () => { | ||
expect(k8s.mebibytes("1Mi")).to.equal(Bytes.MiB / Bytes.MiB); | ||
expect(k8s.mebibytes("1Gi")).to.equal(Bytes.GiB / Bytes.MiB); | ||
}); | ||
|
||
it("Should handle no unit", () => { | ||
expect(k8s.mebibytes("100000")).to.equal(100000 / Bytes.MiB); | ||
expect(k8s.mebibytes("1e9")).to.equal(1e9 / Bytes.MiB); | ||
expect(k8s.mebibytes("1.5E6")).to.equal((1.5 * 1e6) / Bytes.MiB); | ||
}); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.