Newsletter
TechAnV Blog
Get updates on security engineering, Rust, eBPF, and DevSecOps. No spam, unsubscribe anytime.
Check your inbox and click the confirmation link to complete your subscription.
Increasing the time limit for a Google Cloud Scheduler task#
In VIAL issue 724 a Cloud Scheduler job which triggered a Cloud Run hosted export script - by sending an HTTP POST to an endpoint - was returning an error. The logs showed the error happened exactly three minutes after the task started executing.
Turns out the HTTP endpoint (which does a lot of work) was taking longer than three minutes, which is the undocumented default time limit for Cloud Scheduler jobs.
Unfortunately it’s not possible to increase this time limit using the Cloud Scheduler web console, but it IS possible to increase the limit using the CLI gcloud tool.
To list the scheduler jobs:
1~ % gcloud beta scheduler jobs list --project django-vaccinateca2ID LOCATION SCHEDULE (TZ) TARGET_TYPE STATE3api-export-production us-west2 every 1 minutes (America/Los_Angeles) HTTP ENABLED4api-export-staging us-west2 every 1 minutes (America/Los_Angeles) HTTP ENABLED5mapbox-export us-west2 0 2,9,10,11,12,13,14,15,16,17,18,21 * * * (America/Los_Angeles) HTTP ENABLED6resolve-missing-counties-production us-west2 */10 * * * * (America/Los_Angeles) HTTP ENABLED7resolve-missing-counties-staging us-west2 */10 * * * * (America/Los_Angeles) HTTP ENABLED8vaccinatethestates-api-export-production us-west2 */10 * * * * (America/Los_Angeles) HTTP ENABLED9vaccinatethestates-api-export-staging us-west2 */10 * * * * (America/Los_Angeles) HTTP ENABLEDTo increase the limit for one of them by name:
1gcloud beta scheduler jobs update http \2 vaccinatethestates-api-export-production \3 --attempt-deadline=540s \4 --project django-vaccinatecaYou can see the limit using describe:
1~ % gcloud beta scheduler jobs describe vaccinatethestates-api-export-production --project django-vaccinateca2attemptDeadline: 180s3description: Hit /api/exportVaccinateTheStates to export to api.vaccinatethestates.com4 bucket5httpTarget:6 headers:7 Authorization: Bearer 27:...8 User-Agent: Google-Cloud-Scheduler9 httpMethod: POST10 uri: https://vial.calltheshots.us/api/exportVaccinateTheStates11lastAttemptTime: '2021-07-08T23:40:00.992830Z'12name: projects/django-vaccinateca/locations/us-west2/jobs/vaccinatethestates-api-export-production13retryConfig:14 maxBackoffDuration: 3600s15 maxDoublings: 516 maxRetryDuration: 0s17 minBackoffDuration: 5s18schedule: '*/10 * * * *'19scheduleTime: '2021-07-08T23:50:00.061563Z'20state: ENABLED21status:22 code: 223timeZone: America/Los_Angeles24userUpdateTime: '2021-06-10T23:34:48Z'