2
votes

Startign today, I'm unable to deploy cloud functions using gcloud cli.

Here is my gloud command to deploy cloud function:

gcloud functions deploy chatbot_api_gateway_002_test --runtime python37 --trigger-http --entry-point process --set-env-vars VERIFICATION_TOKEN=sometokenhere,PUBSUB_TOPIC=entrypointfunction001,GOOGLE_CLOUD_PROJECT=cs-be-dev,DEST_URL=__undefined_yet__,DEST_URLS_TIMEOUT=2 --memory=2GB --region=asia-northeast1

I'm getting an error:

Deploying function (may take a while - up to 2 minutes)...failed.

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: Build has timed out

I used to work same script 1 hour ago, but now- no one in the team is able to deploy cloud functions and getting the same error.

deployment failed

In the stackdrive logs i see only this:

 {
 insertId: "rr5a8qctoo"  
 logName: "projects/be-dev/logs/cloudaudit.googleapis.com%2Factivity"  

operation: {
  id: "operations/c2F0YWNzLWJlLWRldi9hc2lhLW5vcnRoZWFzdDEvY2hhdGJvdF9hcGlfZ2F0ZXdheV8wMDJfdGVzdC9SMGdpR0ZRWk13aw"   
  last: true   
  producer: "cloudfunctions.googleapis.com"   
 }

protoPayload: {
  @type: "type.googleapis.com/google.cloud.audit.AuditLog"   

authenticationInfo: {
   principalEmail: "[email protected]"    
  }
  methodName: "google.cloud.functions.v1.CloudFunctionsService.CreateFunction"   

requestMetadata: {

destinationAttributes: {
   }

requestAttributes: {
   }
  }
  resourceName: "projects/be-dev/locations/asia-northeast1/functions/chatbot_api_gateway_002_test"   
  serviceName: "cloudfunctions.googleapis.com"   

status: {
   code: 3    
   message: "INVALID_ARGUMENT"    
  }
 }
 receiveTimestamp: "2020-02-05T09:53:42.771914617Z"  

resource: {

labels: {
   function_name: "chatbot_api_gateway_002_test"    
   project_id: "be-dev"    
   region: "asia-northeast1"    
  }
  type: "cloud_function"   
 }
 severity: "ERROR"  
 timestamp: "2020-02-05T09:53:42.153Z"  
}

Any suggestions on how to fix it please?

2
Not really an Answer so apologies in advance - There seems to be a fair few people having similar problems starting this afternoon (myself included). Therefore, I would imagine that there's an issue on Google's side. I don't think there's much to be done other than "Send Feedback" from the google cloud console. Although I'd love to hear any solutions if anyone finds anything!Besperk
@Besperk - right, and this is a bit scary- we suspect its a problem on the google side- but according to google cloud dashboard (status.cloud.google.com/summary)- no outages occur in the last 24 hours.user1503452

2 Answers

3
votes

It reads message: "INVALID_ARGUMENT" so any of the arguments might be incorrect (the change-log sometimes lists breaking changes). See gcloud functions deploy and compare; for example:

Allowed values are: 128MB, 256MB, 512MB, 1024MB, and 2048MB.

Therefore 2GB might eventually be an INVALID_ARGUMENT and (NAME : --region=REGION) also is being declared as a positional argument. Try to get more output with --verbosity=info or debug:

gcloud functions deploy \
    chatbot_api_gateway_002_test \
    --region=asia-northeast1 \
    --runtime python37
    --trigger-http \
    --memory=2048MB \
    --verbosity=info

--entry-point would typically be the directory-name of the function,
eg. helloworld for functions/helloworld/main.py as the entry point.

2
votes

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: Build has timed out

I would like you to propose two different workaround that may resolve your issue with Cloud Functions timing out during deployment.

This could happen because the timeout flag is set low or because the deployment is taking more than the specified in the timeout flag, and thus, causing the Cloud Function to fail to deploy.

  1. When using the gcloud functions deploy you could specify the timeout in seconds using the --timeout flag.

    As described here it will set the function execution time in seconds. It defaults for existing functions, but in your case, it would be 60 seconds by default since you are creating a new one. If you feel like 60 seconds is not enough to deploy your code try increasing the value.

    Keep in mind that it cannot be more than 540 seconds.

   gcloud functions deploy … --timeout [VALUE_SECONDS]
  1. Given you are facing this timeout issue during deployment, you could configure the behaviour of a specific aspect of the Cloud SDK that should resolve your issue.

    As described here using the command gcloud config set will set the specified property in your active configuration only. In order to increase the total timeout you could use cloud_buil_timeout which as described here waits for the Docker build to fully complete during the deployment.

    To sum up, you could try to run the following command:

   gcloud config set app/cloud_build_timeout VALUE

I hope it helps.