0

I have a Google Cloud Trigger that triggers cloud build on Github push.

The problem is that the Cloud Build shows no logs. I followed this doc but can not find any logs on neither the Cloud Build log nor the Logs Explorer (see the image below)

enter image description here

This is my cloudbuild.yaml

steps:
# install dependencies
- name: node:16
  entrypoint: yarn
  args: []
# create .env file
- name: 'ubuntu'
  args: ['bash', './makeEnv.sh']
  env: 
    - 'GCP_SHOPIFY_STOREFRONT_ACCESS_TOKEN=$_GCP_SHOPIFY_STOREFRONT_ACCESS_TOKEN'
    - 'GCP_SHOPIFY_DOMAIN=$_GCP_SHOPIFY_DOMAIN'
# build code
- name: node:16
  entrypoint: yarn
  args: ["build"]
# deploy to gcp
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  entrypoint: 'bash'
  args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy --promote']
timeout: "1600s"
options:
  logging: CLOUD_LOGGING_ONLY

The build failed but it actually create a subsequence App Engine build that successfully deploy a version to App Engine. But that version is not auto-promoted (see the image below)

enter image description here

Duannx
  • 7,501
  • 1
  • 26
  • 59
  • Where are you logs stored? – Tushar Gupta Aug 30 '22 at 11:26
  • @Tushar Honestly I don't know where my logs are stored. As you can see in my `cloudbuild.yaml` file I have the options `logging: CLOUD_LOGGING_ONLY`. I added it because it is the only option that makes the build work. I thought the logs should be stored in Logs Explorer as the document points out but it isn't. – Duannx Aug 30 '22 at 14:03
  • you may have a look at this [link](https://stackoverflow.com/a/60324051/18265638) – Sathi Aiswarya Aug 31 '22 at 08:25
  • @SathiAiswarya I saw that answer but I'm in the Owner role. So I think I would have full access to everything. Is it right? – Duannx Aug 31 '22 at 09:31
  • To view build logs, you require additional permissions depending on whether you're storing your build logs in the default Cloud Storage bucket or in a user-specified Cloud Storage bucket, see [viewing build logs](https://cloud.google.com/build/docs/securing-builds/store-manage-build-logs#viewing_build_logs) – Sathi Aiswarya Aug 31 '22 at 11:08
  • @SathiAiswarya I added all the roles that were listed in that docs but the logs are still empty – Duannx Aug 31 '22 at 11:33
  • Have you tried triggering again? If you are still facing the issue,Seems to get your issue resolved I would recommend to create a [Support Case with Google Cloud](https://cloud.google.com/support-hub) as it requires more in-depth analysis by inspecting your project. – Sathi Aiswarya Sep 01 '22 at 09:20
  • @SathiAiswarya I tried to re-trigger so many times but no luck. Support Case is the last solution. And Google charges it monthly (so sad). Thank you for taking your time with me. – Duannx Sep 01 '22 at 15:38
  • 1
    @SathiAiswarya I mentioned you here to notify you that I found the answer. It is really useful for me. I think that it could be useful for you too so I do this to say thank you in another way :) – Duannx Sep 07 '22 at 03:38

2 Answers2

2

I do not have all the details, so trying to help with all the above information mentioned.

As I can see you are using CLOUD_LOGGING_ONLY and not been able to see the log in the log explorer and considering you have all the permissions to access the logs.

I would suggest you to look into the service account that you are using for cloud build must at least have the role: role/logging.logWriter or permission:logging.logEntries.create permission if it is not the default cloud build SA project-number@cloudbuild.gserviceaccount.com.

Hope this helps :)

NikkU
  • 448
  • 3
  • 10
  • You are the hero, man :D. Thank you very much. We all focused on output permission and forget that we did not have the input :). You bring the other view perspective. And it is not only the answer to this question but also the lesson for me that we should always look at two sides of a problem, don't just focus on what we are seeing – Duannx Sep 07 '22 at 03:32
0

In my case, looking at the Google Cloud Build Service Account (project-number@cloudbuild.gserviceaccount.com) in the Google Cloud IAM console, it was missing the role Cloud Build Service Account. I was also missing logs.

This fixed symptom of a cloud function deploy with the message:

(gcloud.functions.deploy) OperationError: code=3, message=Build failed: {
   "metrics":{},
   "error":{
      "buildpackId":"",
      "buildpackVersion":"",
      "errorType":"OK",
      "canonicalCode":"OK",
      "errorId":"",
      "errorMessage":""
   }
}
Zymotik
  • 6,412
  • 3
  • 39
  • 48