First, it looks like this thread but it is not: An unknown error has occurred in Cloud Function: GCP Python
I deployed a couple of times Cloud Functions and they are still working fine. Nevertheless, since last week, following the same procedure I can deploy correctly, but testing them I get the error “An unknown error has occurred in Cloud Functions. The attempted action failed. Please try again, send feedback”.
In remote the script works perfectly and writes in Cloud Storage.
My Cloud Function is a zip with a python script, loading a csv in Cloud Storage.
The csv weights 160kB, the python script 5kB. So I used 128MiB of memory allocated.
The execution time is 38 secs, almost half of the default timeout.
It is configured to allow just traffic within the project.
Env variables are not the problem
It’s triggered by pub/sub and what I want is to schedule it when I can make it work.
I’m quite puzzled. I have such a lack of ideas right now that I started to think everything works fine but the Google testing method is what is fails… Nevertheless when I run the pub/sub topic in Cloud Scheduler it launches the error log without much info 1. By any chance anyone had the same problem?
Thanks
Advertisement
Answer
Answer of myself from the past:
- Finally “solved”. I’m a processing a csv in the CF of 160kB, in my computer the execution time lasts 38 seconds. For some reason in the CF I need 512MB of Allocated Memory and a timeout larger than 60 secs.
Answer of myself from a closest past:
- Don’t test a CF using the test button, because sometimes it takes more than the max available timeout to finish, hence you’ll get errors.
If you want to test it easily
- Write prints after milestones in your code to check how the script is evolving.
- Use the logs interface. The prints will be displayed there ;)
- Also, logs show valuable info (sometimes even readable).
- Also, if you’re sending for example, to buckets, check them after the CF is finished, maybe you get a surprise.
To sum up, don’t believe blindly in the testing button.
Answer of myself from the present (already regretting the prints thing):
- There are nice python libraries to check logs, don’t print stuff for that (if you have time).