0

i have developed 2 python function scheduled into cloud run. The first function create on demand a job:

def google_cloud_create_job(job_uuid,payload_job,token):
    try:
        url = "https://us-central1-run.googleapis.com/v2/xxxxxxxxxxxxx/locations/us-central1/jobs?jobId=job-name-{0}&validateOnly=False".format(str(job_uuid))

        payload = payload_job

        headers = {
        'Authorization': 'Bearer {}'.format(token),
        'Content-Type': 'application/json'
        }

        response = requests.request("POST", url, headers=headers, data=payload)
        print(response.text)

        return response.status_code
    except Exception as e:
        print(e)

The second function execute the job created:

def google_cloud_run_job(job_uuid, token):
    url = "https://us-central1-run.googleapis.com/v2/xxxxxxxxxxxxxxxxxx/locations/us-central1/jobs/job-name-{0}:run".format(str(job_uuid))
    print(url)

    headers = {
    'Authorization': 'Bearer {}'.format(token),
    'Content-Type': 'application/json'
    }

    response = requests.request("POST", url, headers=headers)

    return response.status_code

Now when i execute this function to create and run 3 jobs, all works fine. If i add a 4° request to create a 4° jobs in sequence, the 4° job is created but not run, and the run function receive a status code response 429. My quota limit for cloud run admin api 'Job run requests per minute per region' is ten and if a do 4 request to create and 4 to run the total is 8, so i'm under quota limit. So Why this error? Any help? On google cloud community no response

dev_
  • 395
  • 1
  • 3
  • 16
  • Can you check this documentation regarding with the [status code 429](https://cloud.google.com/run/docs/troubleshooting#429-max-instances)? – DominicT Jun 08 '23 at 23:31
  • Hello Dominic, i don't think the problem is related to this link. The link is related to max value for istance, instead in this case the problem is on the run job. The yaml file to create job not inclued tha max value for istance contanier. But i could wrong – dev_ Jun 09 '23 at 09:53

1 Answers1

1

One of the possible reasons why error 429 is encountered is because there are multiple instances received per request.

Another possible reason can be the Cold start it happens when the system stops receiving requests and the system went to hibernate it will automatically undergo into the state of Cold start.

Possible work-around:

  1. You can edit the number of your instance count to Maximum number of instances (services). This page helps to configure on different settings.

  2. To prevent a cold start. you can check this documentation regarding with the Minimum Instances (services). For setting up and updating minimum instances you can check out this documentation.

  3. You may request a quota increase by following this steps

If the aforementioned steps didn't work, you may reach out to the Google Cloud Support Hub

Hope this helps

DominicT
  • 388
  • 1
  • 9