Sagar V
Sagar V

Reputation: 12478

Can't deploy cloud functions after deleting old files from artifacts

My Angular website, hosted on Firebase was getting charged for cloud storage since the beginning of this year, because of us.artifacts.<project-id> bucket.

Yesterday, I checked the storage usage and found ~800MB+ data stored on cloud storage. The default bucket is empty and I've stored nothing on it. So all this 800MB storage is used by function builds.

I've 2 Node 10 functions (and 2 node 8 functions) in the project. Node 8 functions are deprecated but it's deployed last year. It won't use us.artifacts bucket.

Following Doug's answer, and a comment,

The dates of the files correspond to the dates of deployment. It should not be hard to figure out which ones are old enough to delete. – Doug Stevenson Sep 15 '20 at 3:56

I deployed both functions yesterday and deleted the files dated before from the bucket. Since then, I'm not able to deploy both functions.

Here's what I've tried so far.

  1. Waited for 8-10 hours and tried re deploying - failed.
  2. Removed both functions from firebase functions dashboard and deployed again - failed.
  3. Removed both functions from firebase dashboard, verified it doesn't exist on Google Cloud functions list, deleted both us.artifacts<project-id> and gcf-sources-<id> buckets from Google cloud. Then deployed the functions as new functions - failed.
  4. Done everything on step 3, except deployment, then renamed both functions and tried deploying again - failed.
  5. Rerun a previous, successful workflow on CircleCI from start - failed.

This is the deployment log

functions: Finished running predeploy script. functions: ensuring

required API cloudfunctions.googleapis.com is enabled... functions:

ensuring required API cloudbuild.googleapis.com is enabled...

functions: required API cloudbuild.googleapis.com is enabled

functions: required API cloudfunctions.googleapis.com is enabled

functions: preparing functions directory for uploading... functions:

packaged functions (39.63 KB) for uploading functions: functions

folder uploaded successfully functions: current functions in project:

sendEnquiryMessage(us-central1), ssr(us-central1) functions: uploading

functions in project: api(us-central1) functions: creating Node.js 10

function api(us-central1)... functions[api(us-central1)]: Deployment
error. Function failed on loading user code. This is likely due to a
bug in the user code. Error message: Error: please examine your
function logs to see the error cause:
https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs.
Additional troubleshooting documentation can be found at
https://cloud.google.com/functions/docs/troubleshooting#logging.
Please visit https://cloud.google.com/functions/docs/troubleshooting
for in-depth troubleshooting documentation.

Functions deploy had errors with the following functions:
api

The error on firebase console says failed to load user code.

enter image description here

I use CircleCI for CI/CD and even rerunning a previous successful workflow fails throwing this error.

Here's a screenshot from CircleCI rerunning previous workflow

enter image description here

Note: I'm using TypeScript for Cloud functions.

Upvotes: 4

Views: 783

Answers (1)

Sagar V
Sagar V

Reputation: 12478

The issue is resolved. Here's the steps I followed.

  1. Changed Node version from 10 to 12 in functions/package.json
  2. Deleted function from firebase dashboard (even if deploy failed, you can see the name in the dashboard).
  3. Deleted us.artifacts.<project-id> and gcf-sources-<id> buckets from Storage.
  4. Deployed again.

Function has been deployed successfully after the node version change.

Upvotes: 5

Related Questions