Closed dpinart-uxland closed 3 years ago
Hmm... that does indeed sound strange. I'll try to reproduce it and see what I can find.
I've just managed to deploy via Cloud Build myself pretty simply. It tooks a few attempts to get the IAM permissions right, but then it was straightforward.
This is my cloudbuild.yaml
file:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- functions
- deploy
- issue176
- --entry-point=Issue176.Function
- --runtime=dotnet3
- --trigger-http
- --allow-unauthenticated
I just ran dotnet new -i gcf-http
and then gcloud builds submit .
Please could you give more details about your function? Does it deploy correctly if you use gcloud functions deploy
locally?
Hi @jskeet Thanks for yur interest.
No, I haven't tried to deploy the cloud function locally yet. I'll try it later and will let you know
This is a real project, meaning it references two other projects in the same solution (al same folder) and it uses Dependency Injection. Not sure if the "The library 'libhostpolicy.so' required to execute the application was not found in '/workspace/bin/'." error is meaningful. Maybe I should google about it
Our deployments are a bit complicated. We have several GCP projects in our organization. In fact, for each "project" we have 3 GCP projects, one per each environment (dev, QA, production)
We have an extra project that holds all the repos and all the triggers. So for each repo we have 3 triggers for branches (dev, QA and production).
Below there's the cloudbuild.yaml we are using:
steps:
- name: gcr.io/cloud-builders/gsutil
args: ['cp', '${_ENV_PATH}', 'env.yaml']
- name: gcr.io/cloud-builders/gcloud
args: [ "functions", 'deploy', "invoice-parser",
'--entry-point', 'Galenicum.POInvoiceParser.FileParsedHandler',
'--set-build-env-vars=GOOGLE_BUILDABLE=POInvoiceParser',
'--runtime', 'dotnet3',
'--trigger-topic', 'po-invoice-scanned',
'--env-vars-file=env.yaml',
'--region=europe-west3',
'--project=${_TARGET_PROJECT_ID}']
It's a quite common build pipe in our projects. We do store environment variables in the repositories project storage, so we do have a build environment variable "_ENV_PATH" that is first copied to the step as env.yaml, then, this file is used as the env vars file '--env-vars-file=env.yaml'. Another build environment variable, _TARGET_PROJECT_ID, is used to set at wich project the function must be deployed
Okay, I'd definitely start by getting it working locally first. If that fails, I would suggest reducing it to a minimal example that demonstrates the problem. (I did a bit of research about that error earlier, and it's not a massively uncommon one - but I'd like to see more details before guessing as to the cause.)
If it works when deploying directly but fails when deploying from CloudBuild, that will be a completely different set of diagnostic steps. Either way though, it would be really helpful if you could put together a complete but minimal example that demonstrates the problem.
Sure,
thanks a lot Jon. I'll try it later
I finally could deploy my function!!! As I'm setting build environment vars, I had to invoke cloud beta functions. Besides, I don't know why but I couldn't deploy my original project. I just created a very basic new project with the cloud functions template that got injected as a dependency the service from my original project and that's all
The final cloudbuild.yaml;
steps:
- name: gcr.io/cloud-builders/gsutil
args: ['cp', '${_ENV_PATH}', 'env.yaml']
- name: gcr.io/cloud-builders/gcloud
args: [ 'beta', 'functions', 'deploy', "invoice-parser",
'--entry-point', 'POInvoiceFunction.Function',
'--set-build-env-vars', 'GOOGLE_BUILDABLE=POInvoiceFunction',
'--runtime', 'dotnet3',
'--trigger-topic', 'po-invoice-scanned',
'--env-vars-file=env.yaml',
'--region=europe-west3',
'--project=${_TARGET_PROJECT_ID}']
And that's all!
It's really nice we can finally deploy .net core cloud functions
I'm very glad to hear it's sorted. Now I look again, I believe it's because of using GOOGLE_BUILDABLE
which is only in beta. Sorry for not thinking of that before... Do raise other issues if you come across problems though!
Hi I'm trying to deploy a cloud function using a cloudbuild trigger.
Apparently it seems it is working fine until the pipe terminates with a criptic error:
Visiting the build logs I see:
The function appears in the project function list marked in red. Going into the function logs I get an "A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/workspace/bin/'.",
Any clue?
Below there are last log entries