diff --git a/src/deploy/functions/backend.ts b/src/deploy/functions/backend.ts index d73d760e530..9e891b6b84d 100644 --- a/src/deploy/functions/backend.ts +++ b/src/deploy/functions/backend.ts @@ -23,6 +23,7 @@ export interface ScheduleTrigger { schedule?: string; timeZone?: string | null; retryConfig?: ScheduleRetryConfig | null; + attemptDeadline?: string | null; } /** Something that has a ScheduleTrigger */ diff --git a/src/deploy/functions/build.ts b/src/deploy/functions/build.ts index 6c68bdeb24c..8f60b417357 100644 --- a/src/deploy/functions/build.ts +++ b/src/deploy/functions/build.ts @@ -148,6 +148,7 @@ export interface ScheduleTrigger { schedule: string | Expression; timeZone?: Field; retryConfig?: ScheduleRetryConfig | null; + attemptDeadline?: Field; } export type HttpsTriggered = { httpsTrigger: HttpsTrigger }; @@ -602,6 +603,9 @@ function discoverTrigger(endpoint: Endpoint, region: string, r: Resolver): backe if (endpoint.scheduleTrigger.timeZone !== undefined) { bkSchedule.timeZone = r.resolveString(endpoint.scheduleTrigger.timeZone); } + if (endpoint.scheduleTrigger.attemptDeadline !== undefined) { + bkSchedule.attemptDeadline = r.resolveString(endpoint.scheduleTrigger.attemptDeadline); + } if (endpoint.scheduleTrigger.retryConfig) { const bkRetry: backend.ScheduleRetryConfig = {}; r.resolveInts( diff --git a/src/deploy/functions/runtimes/discovery/v1alpha1.ts b/src/deploy/functions/runtimes/discovery/v1alpha1.ts index 8afaeb1f016..9b4264b2383 100644 --- a/src/deploy/functions/runtimes/discovery/v1alpha1.ts +++ b/src/deploy/functions/runtimes/discovery/v1alpha1.ts @@ -222,6 +222,7 @@ function assertBuildEndpoint(ep: WireEndpoint, id: string): void { schedule: "Field", timeZone: "Field?", retryConfig: "object?", + attemptDeadline: "Field?", }); if (ep.scheduleTrigger.retryConfig) { assertKeyTypes(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, { @@ -320,6 +321,7 @@ function parseEndpointForBuild( // invalid values before actually modifying prod. schedule: ep.scheduleTrigger.schedule || "", timeZone: ep.scheduleTrigger.timeZone ?? null, + attemptDeadline: ep.scheduleTrigger.attemptDeadline ?? null, }; if (ep.scheduleTrigger.retryConfig) { st.retryConfig = {}; diff --git a/src/gcp/cloudscheduler.ts b/src/gcp/cloudscheduler.ts index 8682a021117..0d0dc218415 100644 --- a/src/gcp/cloudscheduler.ts +++ b/src/gcp/cloudscheduler.ts @@ -36,6 +36,7 @@ export interface HttpTarget { httpMethod: HttpMethod; headers?: Record; body?: string; + attemptDeadline?: string; // oneof authorizationHeader oauthToken?: OauthToken; @@ -249,6 +250,9 @@ export async function jobFromEndpoint( endpoint.serviceAccount ?? (await gce.getDefaultServiceAccount(projectNumber)), }, }; + if (endpoint.scheduleTrigger.attemptDeadline) { + job.httpTarget.attemptDeadline = endpoint.scheduleTrigger.attemptDeadline; + } } else { assertExhaustive(endpoint.platform); }