Closed remie closed 1 year ago
Ok, after some digging around I've discovered that the issue was actually related to some 1st gen code still being executed, which caused the 2nd gen deployment to fail. After migrating the v1 code to v2, the deployment succeeded.
Unfortunately, the deployment message was unclear. Perhaps this issue can be adjusted to provide better logging of failed deployment because the health check failure itself was not the real problem, it was the consequence of a deployment failure.
@remie Thanks for following up and lettings us know about the issue.
To make sure I understand the issue - the healthcheck failure was real, and it was because code related to 1st Gen function was failing for 2nd Gen?
What message was actually helpful in debugging your issue? I would love to find a way to expose them in the cli if possible.
Hey @remie. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
Since there haven't been any recent updates here, I am going to close this issue.
@remie if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
Hey any update? I am facing this issue. I have a repo that uses alot of v1 cfs but have started to move the newer ones to v2, it has been working so far not sure what went wrong with this one.
okay so I did something and it just worked fine, so I changed the structure of how my cloud functions were and introduced a new structure and in my index js I was importing index js of another root folder which exported all the cfs in the above folder. So one of the exports had a wrong case letter to the connected file and due to which gcp couldn't find the root target and I was getting the error, fixing that worked for me.
This is now happening for me all of the sudden.
@taeold
Same here. adding a new 2nd Gen onSchedule function while all others are v1 functions, causes:
Could not create or update Cloud Run service sendschedulednotifications, Container Healthcheck failed. Revision 'sendschedulednotifications-00001-gem' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information.
I've spent 24 hours on this and still can't find the answer. We're being forced to upgrade to Gen 2 in september and i can't even deploy a test Gen 2 without failure. Even the most basic example of printing out the date from the docs doesn't work. It's always the same message.
"Could not create or update Cloud Run service test, Container Healthcheck failed. Revision 'test-00001-dah' is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information."
Although it mentions a port I don't think it has anything to do with a port. Even responding to a simple http request fails. Even this fails: exports.date = onRequest((req, res) => { const date = new Date(); console.log(date) });
Also the log it refers to just repeats that message again.
おかしな場所でnpm installを行っていることが原因かもしれません。 npm installによって作成されたnode_modulesフォルダをすべて削除し、再度npm install→deployを行うとうまくいきました。
I found the answer to this for me in case anyone has the same issue. If you have Gen 1 and Gen 2 functions in the same file and you have a functions.config() ANYWHERE in your project your gen2 functions will not work. Unfortunately the error for this is that obscure port error and "unknown trigger" message. The fix is to convert your entire project to parameterized configuration: https://firebase.google.com/docs/functions/config-env?gen=2nd#params
Again even if you don't use functions.config() in your gen 2 functions, they will kill your deployment. Firebase makes it seem like you can mix and match gen1 and gen2, BUT YOU CANNOT. There might be a way if you use the new code division features, but with a regular project you cannot do it. Unfortunately this is not documented.
I had to make this change
For anyone who is still suffering from this - misleading - error message: For some reason, Firebase and Cloud Run keep bits and pieces of Gen 1 libs in unexpected ways. The way that I finally overcame the issue was a deep clean up. Yes that includes wipe out the entire functions/node_modules followed by npm i.
After that search your entire code and replace any reference to functions.config() with process.env
BELIEVE IT OR NOT, THAT INCLUDES COMMENTED CODES ALSO initializeApp()
As silly it sounds, if you are deploying function a() and somehow in your function b() - which you are not deploying- there is functions.config()
hidden somewhere, your deployment will fail.
Do the clean up.
[REQUIRED] Environment info
firebase-tools: 12.6.2
Platform: CircleCI (cimg/node:16.18-browsers)
[REQUIRED] Test case
We use the following code to export the Cloud Tasks:
The Cloud Task exports are picked up during
yarn run firebase deploy -f --only functions
in the CircleCI container:[REQUIRED] Steps to reproduce
N/A
[REQUIRED] Expected behavior
I would expect Firebase to register the Cloud Task and take care of all the plumbing in order to make
onTaskDispatch
work.[REQUIRED] Actual behavior
The firebase deploy fails with the following error:
I am more than happy to provide actual GCP project information and log files privately if necessary.