4

I tried to deploy a cloud function on the google cloud platform using the my console. The command I used was,

gcloud functions deploy function_name --runtime=python37 --memory=1024MB --region=asia-northeast1 --allow-unauthenticated --trigger-http

But I am getting this error,

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: could not resolve storage source: googleapi: Error 404: Not Found, notFound

I tried googling around but it seems like no one had faced this error message before. I have also tried changing project and deployment is working fine.

gcloud config set project another_project

Appreciate it if anyone have any idea on what is causing this error and how I can solve it. Thanks!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
Denzel
  • 358
  • 5
  • 19
  • If you are able to deploy the same function in another project I will take a look at the specific troublesome project's configuration. Make sure that the account making the deployment has access to write to the staging bucket where the source code is stored. You can always use the [--stage-bucket](https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--stage-bucket) flag in order to control what bucket to use. Is this the first deployment of the function or a subsequent deployment? – Daniel Ocando Nov 15 '20 at 11:09
  • Hello Daniel, yea this is a subsequent deployment of the cloud function. It's weird since it was working perfectly fine recently. Any idea where can I check the deployment's write access to create the staging bucket? Thanks! – Denzel Nov 15 '20 at 14:21
  • I have deleted the old existing cloud function and removed the buckets. I am trying to redeploy it as a brand new cloud function but im still facing the same error. – Denzel Nov 15 '20 at 15:13
  • The service account involved in making the bucket operations should be the [Google Cloud Functions Service Agent service account](https://cloud.google.com/functions/docs/concepts/iam#google_cloud_functions_service_agent_service_account). Nonetheless this will be all the [administrative service accounts](https://cloud.google.com/functions/docs/concepts/iam#administrative_service_accounts) involved for a deployment. Make sure they have the relevant roles assigned as per the public docs as I wasn't able to reproduce that exact error message by following your instructions. – Daniel Ocando Nov 16 '20 at 14:36
  • If this keep failing and since the issue is not easily reproducible I will recommend you to [open a support case](https://cloud.google.com/support/docs/manage-cases#creating_cases) if you have purchased a [support plan](https://cloud.google.com/support/docs) or giving a full reproducible case on the [public issue tracker](https://developers.google.com/issue-tracker#public_users) – Daniel Ocando Nov 16 '20 at 14:40

3 Answers3

5

As per the documentation here - https://cloud.google.com/functions/docs/building it says that : Because Cloud Storage is used directly in your project, the source code directory for your functions is visible, in a bucket named:

gcf-sources-<PROJECT_NUMBER>-<REGION>

Therefore, if you delete the bucket in cloud storage, then you need to re create this bucket. For example if your project number is 123456789 running on asia-south1 then the bucket name should be: gcf-sources-123456789-asia-south1

Once you re create the bucket then you can use gcloud or firebase cli to deploy and it should work normally.

Hope this helps. It worked for me!

Enjoy!

Oru
  • 131
  • 2
  • 13
  • 1
    My guy - this worked for me too. I didn't know what the storage bucket location/region was so I went to logging > log explorer to find the name that was created when function was deployed first time round (or before I deleted the bucket). – AK91 Dec 20 '20 at 14:54
1

Please check if a bucket named gcf-sources-**** is available. If not, you will need to contact gcloud support to request that particular bucket to be rebuiled.

AgentFog
  • 11
  • 2
0

Update:

https://issuetracker.google.com/175866925


Update from GCP Support: That does not resolve my problem at all.

First they said they need to recreate that bucket. Meanwhile they said that does not resolve the problem and they are still investigating the problem.

Just for testing I created that Bucket my self as Oru said.

Still the same error. I will update this tread when I got new information.

AgentFog
  • 11
  • 2