New to GCP: Deploying basic Python cloud function fails - google-cloud-platform

This may be a very simple question, but I'm getting persistent errors when trying to deploy a basic Python cloud function. I created this in the main.py file.
def hello_http(request):
return 'Success!'
Deployment failure:
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.

Found out that Entry Point had to be the same name as the defined function.

Related

Upload data from cloud storage to bigquery

[The issue is resolved, Stackoverflow does not allow to delete the question, the issue was a mistmatch in schema]
I have a piece of code which uploads data from cloud storage into bigquery correctly. I run the code locally and works. Now I moved the code to cloud functions, and it fails, could you help me how I can fix it?
The logs : "Function cannot be initialized. Error: function terminated…"
Check in Cloud Logging to have more info on the error, this link is interesting regarding Cloud Functions troubleshooting :
Function cannot be initialized. Error: function terminated.
Recommended action: inspect logs for termination reason. Additional
troubleshooting information can be found in Logging.

Error: Asset 'webhooks/ActionsOnGoogleFulfillment' cannot be deployed

I wanted to build a Google assistant with custom actions using actions-sdk. Since I am new to this, I have followed the steps in the tutorial "Build Actions for Google Assistant using Actions SDK (Level 1)" as it is, inorder to build a sample assistant. I followed the tutorial as it is. However, in step 5(Implement fulfillment), when trying to test the the fulfillment by running the command
gactions deploy preview
I am getting the below output in the terminal with error
Sending configuration files...
Sending resources...
Waiting for server to respond. It could take up to 1 minute if your cloud function needs to be redeployed.
[ERROR] Server did not return HTTP 200.
{
"error": {
"code": 400,
"message": "Asset 'webhooks/ActionsOnGoogleFulfillment' cannot be deployed. [An operation on function cf-_CcGD8lKs_F_LHmFYfJZsQ-name in region us-central1 in project <my-project-id> is already in progress. Please try again later.]"
}
}
And when I checked the "Google Cloud Platform -> Cloud Functions Console" for this project, the following is seen.
Image 1(Screenshot)
Cloud Platform Cloud Functions Console
A failed deploy of cloud function with an exclamation mark. And if I delete that functions, then immediately a new function is deployed automatically. But instead of an exclamation mark, a spinning wheel symbol(loading/still deploying) mark is present. I cannot delete that cloud function if it is still loading/deploying. Then after 10-15 min, the spinning symbol changes to exclamation symbol. And then if I delete it, then again a new one automatically appears. And it goes on like this
Image 2 (Screenshot)
Cloud Platform Cloud Function Console
This problem arises only when implementing a webhook/fulfillment(Step 5). For static Actions' response, it successfully deploys for testing on entering the command "gactions deploy preview".(Step 1 to Step 4 are successfully implemented)
I have followed the tutorial as it is, hence the code and directory structure is the same as in tutorial,(only the project-id or actions-console project name will be different).
Github Repository for Code
Since, this is only for the tutorial, at present I am not using a billing account, instead did the following changes in package.json(changed node version from 10 to 8.).
"engines": {
"node": "8"
},
Due to this continuous automatic failed deployment, when I try to explicitly deploy the project, as mentioned above, this error occurs.
"An operation on function cf-_CcGD8lKs_F_LHmFYfJZsQ-name in region us-central1 in project <my-project-id> is already in progress. Please try again later".
Can anyone please suggest how to stop this continuous automatic failed deployment of the cloud functions, so that the function I deploy will be successfully deployed? Would really appreciate your help.
(Note: This is the first time I have posted a question in stack overflow, so please let me know if there are any mistakes or stack overflow question conventions I might not have followed. I will improve it.)
Posting this as Community Wiki as it's based in the comments.
As clarified the issue seems to be the billing account, as the tutorial mentions that it's necessary to have one set for the Cloud Functions to be deployed correctly. Besides that, it's not possible to deploy Cloud Functions (webhooks) without a billing account, so yes, even though that you are not using Node.js 10, you will need to have a billing account configured for your project.
To summarize, billing account will be needed to avoid any possible deployment failure, even if you are not using Node.js 10, as explained in the followed tutorial.

Error in following google cloud workflow tutorial using nodejs 10 runtime

I'm trying to follow https://cloud.google.com/dataproc/docs/tutorials/workflow-function, I have edited the workflow template a bit, but the issue I'm getting is at google cloud function. The tutorial asks to choose runtime as nodejs8, when I do that I get error as
Error: Node.js v10.0.0 is a minimum requirement. To learn about legacy version support visit: https://github.com/googleapis/google-cloud-node#supported-nodejs-versions
When I change the runtime to nodejs10 I get error at cloud function as
TypeError: client.workflowTemplatePath is not a function
at exports.startWorkflow (/workspace/index.js:18:16)
at Promise.resolve.then (/layers/google.nodejs.functions-framework/functions-framework/node_modules/#google-cloud/functions-framework/build/src/invoker.js:330:28)
at process._tickCallback (internal/process/next_tick.js:68:7)
Please help me to get this function running, either through nodejs8 or nodejs10
Thanks!
EDIT: As per the comments, turns out it's an api specific issue, can someone good with nodejs skills help me rewrite the instructions provided in the tutorial?

GCP Cloud Run deploy: "Failed to move user code into storage". What does this mean?

Deploying a new service into Google Cloud Run fails with the message:
Failed to move user code into storage, please verify the pod
configuration and try it again.
What does this mean, and how can one go about debugging it?
Just for the sake of giving this question an answer. All the credit should go to AhmetB and his insight about this being a Known issue to Google, In which a missing or invalid entrypoint will cause this issue to surface.
I have found a Public Issue Tracker here, in which this issue has also been forwarded to Google by that channel. Google will be delivering further information on that PIT.

Enabling GCP Cloud Machine Learning Engine error

As I was trying to access Cloud ML Engine in GCP, I was asked to enable its API first. So when I did it, I got the following error:
Update failed with following error(s) for project settings: -- Backend Provisioning Error: {ml.googleapis.com INTERNAL: API enabling failed in operation operations/ml_enable_api/xxxxxxxxx/yyyyyyyyyyyyyyyyy for project xxxxxxxxx};
I don't know how to address this issue. Any insight will be appreciated!
Please try again. This most likely indicates a transient error enabling one of the GCP APIs. If the problem persists please email us at cloudml-feedback#google.com.