firebase-tools
firebase-tools copied to clipboard
fix: prevent failure when deleting cloud function with missing schedule
Closes: 4795
Description
Fixes https://github.com/firebase/firebase-tools/issues/4795#issuecomment-2393788829
When deletion of a pubsub.schedule Cloud Function partially fails, manual interaction is required to fully delete the function.
In my case, deletion of the Cloud Function was unpredictably failing after deleting the associated Cloud Schedule, leaving the function unable to be deleted by a deployment even with the --force CLI flag
This MR changes the behavior of Cloud Functions deployment so that a function which is supposed to have an associated schedule will be deleted if the schedule no longer exists.
Scenarios Tested
Using the latest build of master @ a54e4ff20cc0aca11d89e2f6b31c35f063918d87
- Deploy a Cloud Function (v1) using
firebase deploy - Confirm the function exists https://console.cloud.google.com/functions/list
- Confirm the schedule for the function exists https://console.cloud.google.com/cloudscheduler
- Delete the schedule associated with the function
a. I am unsure what specific scenarios cause the schedule to be deleted without the function being deleted, but it's happened to me a number of times
b. Notice the
Triggercolumn in the Firebase console becomes blank: - Remove the function from the deployment source code
- Run
firebase deploya. Observe the failure in the deploy logs:HTTP Error: 404, Job not found.b. Observe the final failure notice in the deploy logs:Error: There was an error deploying functions: Error Failed to upsert schedule function <function name> in region us-central1
Using the changes from this merge request
repeat steps 1-5
- Run
firebase deploya. Observe the warning in the deploy logs:
b. Confirm the deployment succeeds and the affected functions have been removed.HTTP Error: 404, Job not found. Trigger for dispatchCampaign not found, continuing with deletion of function
Sample Commands
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
@taeold and @christhompsongoogle are tagged in the associated issue
Fixes #4795