Odai A. Ali
Odai A. Ali

Reputation: 1235

Can't deploy Cloud Functions because of "Unhandled error cleaning up build images"

I've deployed hundreds of function and this is the first time I encounter this issue. Simply, it stops deploying function process, saying:

Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at https://console.cloud.google.com/gcr/images/[project-name]/us/gcf

The way I deploy is through Firebase CLI command: firebase deploy --only functions:nameOfFunction

Question is what are those images I have to delete? Why? How can I solve it?

Upvotes: 39

Views: 23530

Answers (9)

Wonderfull
Wonderfull

Reputation: 1

In my case, I went to https://console.cloud.google.com/gcr/images and deleted the gcf file, so it was solved.

Upvotes: 0

Shubhanker
Shubhanker

Reputation: 9

You can try to delete your function file from Artifact Registry > gcf-artifacts of your project then delete your function. It worked for me!!

PS. You will get a link to your registry in error open that then click on your project name from Breadcrumb then see the gcf-artifact repo which you can check by seeing the location column which matches yours or you can open each one and see name of your function there > open it and delete the last deploy function from there.

Upvotes: 0

nsolent
nsolent

Reputation: 243

General troubleshooting tips given the variety of answers here:

  1. if build is failing, read for other errors further up in the build output
  2. add --debug to your CLI call, i.e.: firebase deploy --only functions --debug

With --debug I found this in my output: "Permission 'artifactregistry.packages.delete' denied on resource"

My solution was to add Artifact Registry Administrator role to the IAM user deploying the function (in addition to Firebase Admin & Service Account User roles).

Upvotes: 14

Ric Barnes
Ric Barnes

Reputation: 23

Check your Function logs, by either navigating through functions in the Firebase console or through https://console.cloud.google.com/logs

For me, the logs indicated that one of my typescript files had compiled under the wrong name and it was messing up the build.

Check the logs!

Upvotes: 0

GorvGoyl
GorvGoyl

Reputation: 49460

  1. Go to https://console.cloud.google.com/apis/api/artifactregistry.googleapis.com/overview
  2. select your project
  3. enable Artifact Registry API enter image description here
  4. deploy functions again

Upvotes: 1

Stefano Spensieri
Stefano Spensieri

Reputation: 21

In my experience going into Cloud Storage didn't solve the issue: there was no image there to be deleted.

I solved by changing the Node version, moving from 18 to 14.0.0

nvm install 14.0.0
nvm use 14.0.0 

Upvotes: 0

Amer NM
Amer NM

Reputation: 179

For me, the issue was caused by a silly typo.

The error:

Functions deploy had errors with the following functions: sendNotification(europe-west) i functions: cleaning up build files... ⚠ functions: Unhandled error cleaning up build images. This could result in a small monthly bill if not corrected. You can attempt to delete these images by redeploying or you can delete them manually at...

The fix was choosing the right region.

The incorrect region:

exports.sendNotification = functions
  .region("europe-west")...

The correct region:

exports.sendNotification = functions
      .region("europe-west3")...

Upvotes: 2

SeanMC
SeanMC

Reputation: 2366

For me the issue appeared to be related to my GCF billing (https://console.cloud.google.com/billing) I had to go to my billing account to see that my payment method was expired or something, and GCF had forecasted a monthly cost of $0.01, so deploying cloud functions was sort of locked until I updated the payment method. Then the deploy immediately worked again after updating it. The build-cleanup console warning also disappeared.

The error I was seeing in my function logs in firebase console was "billing account is not available". Which I found almost zero results for in Google. Which is why I'm posting it here.

Upvotes: 9

Doug Stevenson
Doug Stevenson

Reputation: 317750

Cloud Functions uses another product called Cloud Build to build the server images that actually get deployed. Those images are stored in Cloud Storage, and that storage is billed to your account.

Read more about it:

Watch:

You should be able to locate and delete the files manually in the Google Cloud console. But it sounds like there is a bug here with the files not being cleaned up automatically, so you contact Firebase support directly.

Upvotes: 17

Related Questions