Skip to content

Remove label annotations for genkit functions; they break #8127

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

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/deploy/functions/backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@

/** API agnostic version of a Firebase callable function. */
export type CallableTrigger = {
// NOTE: This is currently unused because GCF 2nd gen labels do not support
// the characterset that may be in a genkit action name.
// This should be set as a Cloud Run attribute once we move to Cloud Run Functions.
genkitAction?: string;
};

Expand Down Expand Up @@ -516,7 +519,7 @@
await loadExistingBackend(context);
}
// loadExisting guarantees the validity of existingBackend and unreachableRegions
return context.existingBackend!;

Check warning on line 522 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
}

async function loadExistingBackend(ctx: Context): Promise<void> {
Expand Down Expand Up @@ -549,8 +552,8 @@
ctx.existingBackend.endpoints[endpoint.region][endpoint.id] = endpoint;
}
ctx.unreachableRegions.gcfV2 = gcfV2Results.unreachable;
} catch (err: any) {

Check warning on line 555 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err.status === 404 && err.message?.toLowerCase().includes("method not found")) {

Check warning on line 556 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .status on an `any` value

Check warning on line 556 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .includes on an `any` value

Check warning on line 556 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value

Check warning on line 556 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .message on an `any` value

Check warning on line 556 in src/deploy/functions/backend.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value
return; // customer has preview enabled without allowlist set
}
throw err;
Expand Down
40 changes: 0 additions & 40 deletions src/gcp/cloudfunctionsv2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,6 @@ describe("cloudfunctionsv2", () => {
[BLOCKING_LABEL]: "before-sign-in",
},
});

expect(
cloudfunctionsv2.functionFromEndpoint({
...ENDPOINT,
platform: "gcfv2",
callableTrigger: {
genkitAction: "flows/flow",
},
}),
).to.deep.equal({
...CLOUD_FUNCTION_V2,
labels: {
...CLOUD_FUNCTION_V2.labels,
"deployment-callable": "true",
"genkit-action": "flows/flow",
},
});
});

it("should copy trival fields", () => {
Expand Down Expand Up @@ -654,29 +637,6 @@ describe("cloudfunctionsv2", () => {
});
});

it("should translate genkit callables", () => {
expect(
cloudfunctionsv2.endpointFromFunction({
...HAVE_CLOUD_FUNCTION_V2,
labels: {
"deployment-callable": "true",
"genkit-action": "flows/flow",
},
}),
).to.deep.equal({
...ENDPOINT,
callableTrigger: {
genkitAction: "flows/flow",
},
platform: "gcfv2",
uri: GCF_URL,
labels: {
"deployment-callable": "true",
"genkit-action": "flows/flow",
},
});
});

it("should copy optional fields", () => {
const extraFields: backend.ServiceConfiguration = {
ingressSettings: "ALLOW_ALL",
Expand Down
6 changes: 0 additions & 6 deletions src/gcp/cloudfunctionsv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,8 @@
* @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 {

Check warning on line 252 in src/gcp/cloudfunctionsv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (err?.message?.includes("maxScale may not exceed")) {

Check warning on line 253 in src/gcp/cloudfunctionsv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .message on an `any` value

Check warning on line 253 in src/gcp/cloudfunctionsv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe call of an `any` typed value
const maxInstances = func.serviceConfig.maxInstanceCount || DEFAULT_MAX_INSTANCE_COUNT;
utils.logLabeledWarning(
"functions",
Expand Down Expand Up @@ -609,9 +609,6 @@
gcfFunction.labels = { ...gcfFunction.labels, "deployment-taskqueue": "true" };
} else if (backend.isCallableTriggered(endpoint)) {
gcfFunction.labels = { ...gcfFunction.labels, "deployment-callable": "true" };
if (endpoint.callableTrigger.genkitAction) {
gcfFunction.labels["genkit-action"] = endpoint.callableTrigger.genkitAction;
}
} else if (backend.isBlockingTriggered(endpoint)) {
gcfFunction.labels = {
...gcfFunction.labels,
Expand Down Expand Up @@ -657,9 +654,6 @@
trigger = {
callableTrigger: {},
};
if (gcfFunction.labels["genkit-action"]) {
trigger.callableTrigger.genkitAction = gcfFunction.labels["genkit-action"];
}
} else if (gcfFunction.labels?.[BLOCKING_LABEL]) {
trigger = {
blockingTrigger: {
Expand Down
Loading