firebase-functions: Cloud Functions not deploying: Build fails

Version info

node: v10.18.1 (Issue is present irrespective of version)

firebase-functions: 3.6.1 (Issue is present irrespective of version)

firebase-tools: 8.12.1 (Issue is present irrespective of version)

firebase-admin: 9.2.0 (Issue is present irrespective of version)

Steps to reproduce

I’ve been trying to deploy my existing project with just a few EJS changes. But it doesn’t deploy even if I redeploy old code.

Expected behavior

Should deploy

Actual behavior

{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":13,"message":"Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=[Name removed]&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3D[ID removed]%0AlogName%3Dprojects%2F[Name removed]%2Flogs%2Fcloudbuild"},"authenticationInfo":{"principalEmail":"[Email removed]"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/[Name removed]/locations/us-central1/functions/app"} 

Were you able to successfully deploy your functions?

No, I ended up with this:

⚠  functions[app(us-central1)]: Deployment error.
Build failed: Build error details not available. Please check the logs at https://console.cloud.google.com/logs/viewer?project=[Name removed]&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3D[ID Removed]%0AlogName%3Dprojects%2F[Name removed]%2Flogs%2Fcloudbuild


Functions deploy had errors with the following functions:
	app


To try redeploying those functions, run:
    firebase deploy --only "functions:app"


To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 111 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I fixed it by deleting us.artifacts.[Project ID].appspot.com

Updating Node JS to version 16 work for me

"engines": { "node": "16" },

I fixed it by deleting us.artifacts.[Project ID].appspot.com

You kind sir. Thank you very much. Worked like a champ. Wish i discovered your solution earlier, wasted 4 hours on this issue. Thank you!

I fixed it by deleting us.artifacts.[Project ID].appspot.com

Thanks. This worked

I fixed it by deleting us.artifacts.[Project ID].appspot.com

@aravindvnair99, The issue is still occurring after deleting the bucket

I fixed it by deleting us.artifacts.[Project ID].appspot.com

where is this file

Please file a support ticket at firebase.google.com/support

Reply for 1st part

@aravindvnair99 Does this look familiar? https://stackoverflow.com/questions/67338215/cloud-function-build-error-failed-to-get-os-from-config-file-for-image/67402286

@taeold Yes, it does. That was the error. Tried checking earlier logs, but I was unable to find them. But as far as I remember, it is the same thing. But I checked for a few recent ones, and I noticed Cloud Functions says something like:

{
  "protoPayload": {
    "@type": "type.googleapis.com/google.cloud.audit.AuditLog",
    "status": {
      "code": 3,
      "message": "Build failed: Build error details not available.Please check the logs at https://console.cloud.google.com/cloud-build/builds;region=us-central1/<redacted>?project=<redacted>. Please visit https://cloud.google.com/functions/docs/troubleshooting#build for in-depth troubleshooting documentation for build related errors."
    },
    "authenticationInfo": {
      "principalEmail": "<redacted>"
    },
    "serviceName": "cloudfunctions.googleapis.com",
    "methodName": "google.cloud.functions.v1.CloudFunctionsService.UpdateFunction",
    "resourceName": "projects/<redacted>/locations/us-central1/functions/app"
  },
  "insertId": "-1nctggc9uk",
  "resource": {
    "type": "cloud_function",
    "labels": {
      "region": "us-central1",
      "project_id": "<redacted>",
      "function_name": "app"
    }
  },
  "timestamp": "2021-06-14T04:43:07.310674Z",
  "severity": "ERROR",
  "logName": "projects/<redacted>/logs/cloudaudit.googleapis.com%2Factivity",
  "operation": {
    "id": "operations/<redacted>",
    "producer": "cloudfunctions.googleapis.com",
    "last": true
  },
  "receiveTimestamp": "2021-06-14T04:43:07.637300980Z"
}

Clicking on the link it gives, takes me to the build details where I can see that step 2 titled “analyzer” is failing :

2021-06-14 10:13:06.779 ISTStep #2 - "analyzer": ERROR: failed to initialize cache: failed to create image cache: accessing cache image "us.gcr.io/<redacted>/gcf/us-central1/<redacted>/cache:latest": failed to get OS from config file for image 'us.gcr.io/<redacted>/gcf/us-central1/<redacted>/cache:latest'

Reply for 2nd part

I’m leaning on closing this issue since it’s grown to be a bucket of all kinds of deployment issue

The issue is the same for most people I believe (I have gone through multiple reports online and I have also helped many who approached me directly face to face / social media platforms). I first faced this issue and then opened this issue tracker on October 15th, 2020. I managed to figure it out on my own and closed it. And for me, the issue came up because I had set a life cycle for the cloud storage on my own. I did so as I ended up getting much higher-than-expected costs for Cloud Storage. Deleting the bucket fixed it for me as I mentioned here: https://github.com/firebase/firebase-functions/issues/795#issuecomment-710091616 and that was a one-time thing for all my projects sitting on Firebase. Also, this was only for Node.js 8 and 10. Node.js 12 did not seem to have this issue back then when I checked.

Later as time passed, I noticed Google was auto adding life cycles, especially to newer projects which was never the case before. So, I stopped manually setting it up. Everything was fine until now where suddenly everyone is facing issues. It is something that changed during that time that is causing the issue and that is when I opened https://github.com/firebase/firebase-tools/issues/3359 and is now occurring irrespective of the Node.js version. It has always been the Cloud Build that is failing due to the life cycle policies. Some recent change to the build process is what’s causing all these issues. Deleting the bucket always fixes it for me. I have not tried deleting images yet. But as far as I can see, it’s the life cycle that is creating issues for most people.

Related issues:

Apart from the ones I listed, Stack Overflow is filled with questions related to:

  • Cloud Function deployments failing due to Cloud Build fails
  • Cloud Storage costs
  • Purposes of storage buckets and their associated costs
  • Cloud Storage lifecycle

Concluding thoughts

But with that said, I feel properly documenting all necessary information in the right place and auto-deleting / cleaning up unnecessary stuff in the right manner after deployment should solve this issue for most if not all people because as far as I have seen, most people have life cycle policies set either manually or automatically from Google’s end. I also feel duplicate issues can be closed so that everything can be tracked in a single place.

@aravindvnair99 Can we delete gcf-sources-<ID>-us-center1? as i see it contains zipped source code for all the functions, but it also maintains previous version as well as those functions which i have deleted. So will it be okay to delete the entire gcf-sources folder and recreate everything by another round of deploy? or it is better to delete individual files(previous version and delete functions) which are not relevant anymore?

Thank you 😃

Hey @i-am-mani!

You just have to delete the contents of the bucket by selecting the main folder and then redeploy. If that doesn’t help, then delete the bucket and it will automatically create it again for you on the next deployment. Things should be fine then.

@inlined you are right. I am paid customer and forgot about the the support because I went through the support in Google Cloud dashboard instead Firebase Console.

Yes, I fixed!

Fixed? I don’t see a log file anywhere. I’ll repeat again that this is a forum for reporting bugs, not troubleshooting general deploy problems. We have many more people employed to help you with the latter than the former. You’ll find very qualified support at your disposal at firebase.google.com/support.

@aravindvnair99 any ideia

@faustoct you need to attach your log files for any of us to pin point your issue.

@aravindvnair99 ok fixed

so what’s the solution?

@faustoct what’s the issue you are facing?

Solved by downgrading Node js version to 12 and CLI also upgraded.

FYI: The staging bucket is a Google-created bucket that was originally used for App Engine uploads. It always has a lifecycle policy because it’s only expected to be used by Google tools and those tools aren’t ever supposed to be putting durable objects there (it is, after all, only a “staging” bucket). IIRC we stopped using the staging bucket for GCF a long time ago, so any issues involving the staging bucket should probably be closed with “upgrade your CLI”.

Google Container Repository does not handle deleting the underlying GCS files cleanly. Adding a lifecycle hook will cause GCF and other tools to break. Any issues involving the artifacts bucket should probably be closed with “Don’t mess with the artifacts bucket. Upgrade your CLI and we will safely purge caches for you”

Are there other outstanding issues that could be considered in-scope, or can this bug be closed? As @taeold commented, “not deploying” is too broad a scope for a single bug. Issues related to container registry failures fit here. Other specific issues/bugs can be new GitHub issues. If you can’t narrow down your trouble deploying to any particular bug, contacting support will probably get you going faster

Also - consider upgrading your firebase cli to 9.14.0. We just shipped a feature where container images will be cleaned up after a successful function deploy!

https://github.com/firebase/firebase-tools/pull/3439

Hey Thanks for your response. I meant can we delete GCF-Sources bucket safely? because on couple of places, its said that deleting the GCF bucket may cause problems. The problem with GCF bucket in my case is that, it contains the functions that are no longer used and probably it contains history of each functions too.

Thanks again!

@i-am-mani Emptying the artifacts is usually more than sufficient. If that doesn’t work (like in my case), then delete the artifacts bucket. If that also doesn’t work, empty the sources bucket. If that also doesn’t work, then delete the sources bucket. It will automatically recreate as needed on deploy.

it does not work for me. for my issue, it’s because of require('../service-account-file.json'), so I need to remove all require https://stackoverflow.com/a/62855195/4340131

hey @aravindvnair99 i debug it. Thank you again for your help!! Take care man!

debug.txt @aravindvnair99 firebase --debug deploy