Have been working on a GCP project involving OCR. Have attempted to follow the tutorial here, but the first function crashes when I try to upload a file to the trigger bucket. Moreover, cloud shell will not allow me to set the env variable GCP_PROJECT; it returns
ERROR: (gcloud.functions.deploy) ResponseError: status=[400], code=[Bad Request], message=[The request has errors
Problems:
environment_variables:
environment variable name GCP_PROJECT is reserved by the system: it cannot be set by users
]
Any suggestions?
I am not 100% sure, but after some work, I am guessing that the answer is that the .json file with the service account being used in the function had to be exported as GOOGLE_APPLICATION_CREDENTIALS in the gcloud SDK when deploying the function.
I got the same error when following this tutorial.
Changing
--set-env-vars "^:^GCP_PROJECT=my_proj:TRANSLATE_TOPIC
to
--project my_proj --set-env-vars "^:^TRANSLATE_TOPIC fixed it.
I have the same error.
I just follow their own tutorial and there is nothing special or customized.
Actually I got errors in every step of the tutorial and search the internet to fix it.
However I stuck on this one.
Related
It appears that you cannot deploy a Gen2 cloud function using gcloud from a cloud source repo unless it is at the top level.
Here's a sample redacted deploy command for a gen 1 python function that works:
gcloud beta functions deploy funcname --source https://source.developers.google.com/projects/projectname/repos/reponame/moveable-aliases/main/paths/pathname --runtime python310 --trigger-http --project=projectname
if you add the -gen2 flag, it fails because it can't find main.py. Error is:
OperationError: code=3, message=Build failed with status: FAILURE and message: missing main.py and GOOGLE_FUNCTION_SOURCE not specified. Either create the function in main.py or specify GOOGLE_FUNCTION_SOURCE to point to the file that contains the function.
If you add main.py to the root of the repo and run the same command, it finds main.py, which indicates to me that it isn't honoring the paths.
There is an additional problem which doesn't matter unless the first one is fixed, which is that if pathname is below the top level (folder/subfolder) gcloud sees that as a syntax error when the gen2 flag is set, but not without it.
Is there any way around this? It is very inconvenient.
Answering as community wiki.As per above comments
There is a bug raised for this at issue tracker. Which is still open further progress can be tracked there.
I'm following this tutorial: https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app for Google Cloud Platform. I'm using the Google Cloud Shell command line. When I got to the step:
To build the container image of this application and tag it for uploading, run the following command:
docker build -t gcr.io/${PROJECT_ID}/hello-app:v1 .
I get an error:
invalid argument "gcr.io//hello-app:v1" for "-t, --tag" flag: invalid reference format
Bear in mind I already have 3 instances cluster (created from Kubernetes Engine) and one VM instance created on its own, existing in my VM instances, created from previous tutorials. Not sure if this has anything to do with the error.
Thanks in advance.
You missed setting PROJECT_ID. In the the "Before you begin" section of the tutorial you linked to it has you run
gcloud config set project [PROJECT_ID]
and then in Step 1 you run
export PROJECT_ID="$(gcloud config get-value project -q)"
After those two commands you should have the shell variable set correctly.
I also got the same error when running
docker build -t gcr.io/${PROJECT_ID}/hello-app:v1 .
but changing it to (my PROJECT_ID is say deepworld123)
docker build -t gcr.io/deepworld123/hello-app:v1 .
fixed it for me. Even though i did set PROJECT_ID=deepworld123.
Your tutorial link doesn't work (it's a link to a GCP dashboard, not a tutorial), but presumably there was a step where you were supposed to set the PROJECT_ID variable, which you skipped. The error message shows nothing between the two slashes where ${PROJECT_ID} appears in your command.
Had a very similar issue involving PROJECT_ID not being set correctly. The solution has to deal with formating as the error message says.
My PROJECT_ID string has the following format companyname.com:companyname-1 After I followed all the steps in the accepted answer the error message was the same.
It turns out the : needs to be replaced by a /. The final gcr.io string looks like:
gcr.io/companyname.com/companyname-1/hello-app:v1
When I try to use the project creation template which is on github, even after changing the appropriate values in config.yaml I am getting following error.
location: /deployments/projectcreation000/manifests/manifest-1534790908361
message: 'Manifest expansion encountered the following errors: Error compiling Python code: No module named apis Resource: project.py Resource: config'
you can find the repo link here : https://github.com/GoogleCloudPlatform/deploymentmanager-samples/tree/master/examples/v2/project_creation
Please help as I need it for production workflow. I have tried "sudo pip install apis" in Cloud Shell but it does not help, even after successful installation of apis module.
you either need to fix the import or move the file, so that apis.py will be found.
The apis module in this context refers to,
not a pip package. Ensure you have all the files in the same relative paths to each other when deploying these samples.
Deploying cloud function with gcloud failed with below message,
ERROR: (gcloud.beta.functions.deploy) OperationError: code=13,
message=Failure in the execution environment
Couldn`t find much information about the error in the cloud function logs.
Running deploy with --verbose debug traces the functions called in the Cloud SDK directory and ends with displaying the below error,
FunctionsError: OperationError: code=13, message=Failure in the
execution environment ERROR: (gcloud.beta.functions.deploy)
OperationError: code=13, message=Failure in the execution environment
Per this Google Public Issue Tracker, the error is due to a very large package.json file hitting an internal restriction. Possible workarounds:
1- Installing your dependencies locally (through 'npm install') and deploying with --include-ignored-files flag.
2- Reduce your package.json to less than 4000 characters
This is an ongoing issue and you can follow the discussion on this thread for related updates.
The status of firebase can be found under:
https://status.firebase.google.com/
Just sharing our experience here, with the hope it helps someone in the future.
In our case we got a similar error:
ERROR: (gcloud.beta.functions.deploy) OperationError: code=13, message=Error setting up the execution environment for your function. Please try deploying again after a few minutes.
This was caused by an import of package.json in the code to read out the version. I.e.:
import { version } from '../package.json';
Transpilation and local invocation of the generated JS code worked as expected with the above line in our code base. After we removed the import, we were able to deploy the function agian.
Some of the GCP errors are broad.
The solution to this for me was my go.mod file had go 1.14 while the GCP only supports go 1.11 or go 1.13
For my case, it was a python environment, and the culprit was a dependency yarl==1.5.1.
As there are no logs, I couldn't tell exactly why yarl was causing the breakage, but downgrading to yarl==1.3.0 fixed the issue for me.
I'm doing the tutorial of basic fulfillment and conversation setup of api.ai tutorial to make a chat bot, and when I try to deploy the function with the command:
gcloud beta functions deploy --stage-bucket venky-bb7c4.appspot.com --trigger-http
(where 'venky-bb7c4.appspot.com' is the bucket_name)
It return the following error message:
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Source code size exceeds the limit
I've searched but not found any answer, I don't know where is the error.
this is the JS file that appear in the tutorial:
/
HTTP Cloud Function.
#param {Object} req Cloud Function request context.
#param {Object} res Cloud Function response context.
*/
exports.helloHttp = function helloHttp (req, res) {
response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working
res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
res.send(JSON.stringify({ "speech": response, "displayText": response
//"speech" is the spoken version of the response, "displayText" is the visual version
}));
};
Neither of these worked for me. The way I was able to fix this was to make sure I was running the deploy from my project directory (the directory containing index.js)
The command creates zip with whole content of your current directory (except node_modules subdirectory) not just the JS file (this is because your function may use other resources).
The error you see is because size of (uncompressed) files in the directory is bigger than 512MB.
The easiest way to solve this is by moving the .js file to its own directory and deploying from there (you can use --local-path to point to directory containing the source file if you want your working directory to be different from directory with function source).
I tried with source option or deploying from the index.js folder and still a different problem exists.
This error usually happens if the code that is being uploaded is large. In my tests I found more than 100MB lead to the mentioned error.
However,
To resolve this there are two solutions.
Update .gcloudignore to ignore the folders which aren't required for your function
Still if option 1 doesn't resolve, you need to create a bucket in storage and mention it with --stage-bucket option.
Create a new bucket for deployment (one time)
gsutil mb my-cloud-functions-deployment-bucket
The bucket you created needs to be unique else it throws already created
Deploy
gcloud functions deploy subscribers-firestoreDatabaseChange
--trigger-topic firestore-database-change
--region us-central1
--runtime nodejs10
--update-env-vars "REDIS_HOST=10.128.0.2"
--stage-bucket my-cloud-functions-deployment-bucket
I had similar problems while deploying cloud functions. What is working for me was specifying the js files source folder.
gcloud functions deploy functionName --trigger-http **--source path_to_project_root_folder**
Also be sure to include all unnecessary folders in .gcloudignore.
Ensure the package folder has a .gitignore file (excluding node_modules).
The most recent version of gcloud requires it in order to not load node_modules. My code size went from 119MB to 17Kb.
Once I've added the .gitignore file, the log printed as well
created .gcloudignore file. See `gcloud topic gcloudignore` for details.