Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 830
Odai A. Ali Avatar asked Aug 01 '21 15:08

Odai A. Ali


4 Answers

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:

  • https://github.com/firebase/firebase-tools/issues/3404
  • https://krasimirtsonev.com/blog/article/firebase-gcp-saving-money

Watch:

  • https://www.youtube.com/watch?v=aHaI0jZ5rwM

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.

like image 134
Doug Stevenson Avatar answered Oct 05 '22 14:10

Doug Stevenson


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.

like image 31
SeanMC Avatar answered Oct 05 '22 15:10

SeanMC


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")...
like image 42
Amer NM Avatar answered Oct 05 '22 15:10

Amer NM


  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
like image 23
GorvGoyl Avatar answered Oct 05 '22 13:10

GorvGoyl