Reputation: 415
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
Upvotes: 0
Views: 397
Reputation: 355
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:
You can edit the number of your instance count to Maximum number of instances (services). This page helps to configure on different settings.
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.
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
Upvotes: 0