Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Function build error - failed to get OS from config file for image

Tags:

I'm seeing this Cloud Build error when I try to deploy a Cloud Function:

"Step #2 - "analyzer": [31;1mERROR: [0mfailed to initialize cache: failed to create image cache: accessing cache image "us.gcr.io/MY_PROJECT/gcf/us-central1/SOME_KEY/cache:latest": failed to get OS from config file for image 'us.gcr.io/MY_PROJECT/gcf/us-central1/SOME_KEY/cache:latest'"

I'm able to build and emulate the cloud function locally, but I can't deploy it due to this error. I was able to deploy just fine until now. I've looked everywhere and I can't find any discussion about this. Anyone know what's going on here?

UPDATE: I deployed a new function 3 days ago and now I can't seem to deploy an update to it. I get the same error. I'm fairly sure this is happening due to the lifecycle rule I set up to ensure I don't keep storing images of functions: Firebase storage artifacts is huge and keeps increasing. This rule is important to keep around because I don't want to pay for unnecessary storage, but it seems like it might be the source of our problem here. Can someone from Google look into this?

like image 475
Sameer Madan Avatar asked Apr 30 '21 17:04

Sameer Madan


People also ask

Why Cloud function deployment failed?

Cloud Functions deployment can fail if the entry point to your code, that is, the exported function name, is not specified correctly. Your source code must contain an entry point function that has been correctly specified in your deployment, either via Cloud console or Cloud SDK.

What is firebase function?

Firebase gives mobile developers access to a complete range of fully managed mobile-centric services including analytics, authentication and Realtime Database. Cloud Functions rounds out the offering by providing a way to extend and connect the behavior of Firebase features through the addition of server-side code.


2 Answers

I got the same error, even for code that deployed successfully before.

A workaround is to delete the Docker images for the failing Firebase functions inside Container Registry and re-deploying the functions. (The images will be re-created upon deploying.)

The error still occurs sporadically, so I suspect this may be a bug introduced in Firebase's deployment process. Thankfully for now, the workaround above resolves the issue every time the error comes up.

like image 128
dkthehuman Avatar answered Oct 24 '22 19:10

dkthehuman


I also encountered the same problem, and solved it by deleting the images in the Container Registry of Firebase Project.

I made a Script at that time, and I'll put it here. The usage is as follows. Please use it if you like.

  1. Install the Google Cloud SDK.
  2. Download the Script
  3. Edit CONTAINER_REGISTRY to your registry name. For example: CONTAINER_REGISTRY=asia.gcr.io/project-name/gcf/asia-northeast1
  4. Grant execute permission. - $ chmod +x script.sh
  5. Execute it. - $ sh script.sh
  6. Deploy your functions.
like image 40
Kichiemon Avatar answered Oct 24 '22 20:10

Kichiemon