Conversation
setTrigger/deleteTrigger threw for platform run. Reuse the v2 Cloud Scheduler path (jobFromEndpoint already targets endpoint.uri with an OIDC token), grant run.invoker to the scheduler service account on create and update, and persist scheduleTrigger in the firebase-functions-metadata annotation so the next deploy reads the service back as scheduled instead of HTTPS.
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for deploying scheduled Dart functions (onSchedule) to Cloud Run. Key changes include updating the fabricator to manage schedule triggers and configure the run.invoker role for the scheduler's service account, as well as preserving schedule trigger metadata in Cloud Run service annotations for backend reconstruction. Corresponding unit tests and a changelog entry have been added. I have no feedback to provide as there are no review comments.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Deploying a Dart function that uses
firebase.scheduler.onSchedulefails:setTrigger()anddeleteTrigger()throwSchedule triggers for Cloud Run functions are not supported yet.forplatform: "run". The Cloud Run service is created first, so the deploy leaves a service with no Cloud Scheduler job.This PR reuses the existing GCFv2 schedule path, since
cloudscheduler.jobFromEndpoint()already handlesrun(HTTP target onendpoint.uriwith an OIDC token):setTrigger/deleteTrigger:rungoes throughupsertScheduleV2/deleteScheduleV2.createRunFunction/updateRunFunction: grantroles/run.invokerto the scheduler's service account (the endpoint'sserviceAccount, else the default compute SA), ascreateV2Function/updateV2Functionalready do.runv2.serviceFromEndpoint/endpointFromService: persistscheduleTriggerin thefirebase-functions-metadataannotation. Without it, the existing service is read back ashttpsTrigger, and the second deploy aborts withChanging from an HTTPS function to a scheduled function is not allowed.Related: #10851 does the same for Firestore event triggers on Cloud Run. The two are independent; this one only touches schedule triggers.
Scenarios Tested
Unit tests added in
fabricator.spec.tsandrunv2.spec.ts.Manually on a real project (europe-west3), with a Dart
onSchedule(schedule: '*/2 * * * *')usingtimeZoneandretryConfig:run.invokerbinding.gcloud scheduler jobs run; the handler gets a 200 and theScheduledEventheaders.timeZone/retryCountupdates the job in place.retryCounttimes.functions:delete) deletes both the service and the job.Sample Commands