From 8cc7c0482016185ff41c64422790d39340da7e3c Mon Sep 17 00:00:00 2001 From: guillaume blaquiere Date: Thu, 16 Jan 2020 18:27:26 +0000 Subject: [PATCH] Added attempt deadline to scheduler resource Signed-off-by: Modular Magician --- plugins/modules/gcp_cloudscheduler_job.py | 31 +++++++++++++++++++ .../modules/gcp_cloudscheduler_job_info.py | 13 ++++++++ .../gcp_cloudscheduler_job/tasks/autogen.yml | 5 +++ 3 files changed, 49 insertions(+) diff --git a/plugins/modules/gcp_cloudscheduler_job.py b/plugins/modules/gcp_cloudscheduler_job.py index d6d90a3..49b86f8 100644 --- a/plugins/modules/gcp_cloudscheduler_job.py +++ b/plugins/modules/gcp_cloudscheduler_job.py @@ -75,6 +75,20 @@ options: required: false default: Etc/UTC type: str + attempt_deadline: + description: + - The deadline for job attempts. If the request handler does not respond by this + deadline then the request is cancelled and the attempt is marked as a DEADLINE_EXCEEDED + failure. The failed attempt can be viewed in execution logs. Cloud Scheduler + will retry the job according to the RetryConfig. + - 'The allowed duration for this deadline is: * For HTTP targets, between 15 seconds + and 30 minutes.' + - "* For App Engine HTTP targets, between 15 seconds and 24 hours." + - 'A duration in seconds with up to nine fractional digits, terminated by ''s''. + Example: "3.5s" .' + required: false + default: 180s + type: str retry_config: description: - By default, if a job does not complete successfully, meaning that an acknowledgement @@ -339,6 +353,7 @@ EXAMPLES = ''' schedule: "*/4 * * * *" description: test app engine job time_zone: Europe/London + attempt_deadline: 320s app_engine_http_target: http_method: POST app_engine_routing: @@ -375,6 +390,19 @@ timeZone: - The value of this field must be a time zone name from the tz database. returned: success type: str +attemptDeadline: + description: + - The deadline for job attempts. If the request handler does not respond by this + deadline then the request is cancelled and the attempt is marked as a DEADLINE_EXCEEDED + failure. The failed attempt can be viewed in execution logs. Cloud Scheduler will + retry the job according to the RetryConfig. + - 'The allowed duration for this deadline is: * For HTTP targets, between 15 seconds + and 30 minutes.' + - "* For App Engine HTTP targets, between 15 seconds and 24 hours." + - 'A duration in seconds with up to nine fractional digits, terminated by ''s''. + Example: "3.5s" .' + returned: success + type: str retryConfig: description: - By default, if a job does not complete successfully, meaning that an acknowledgement @@ -608,6 +636,7 @@ def main(): description=dict(type='str'), schedule=dict(type='str'), time_zone=dict(default='Etc/UTC', type='str'), + attempt_deadline=dict(default='180s', type='str'), retry_config=dict( type='dict', options=dict( @@ -695,6 +724,7 @@ def resource_to_request(module): u'description': module.params.get('description'), u'schedule': module.params.get('schedule'), u'timeZone': module.params.get('time_zone'), + u'attemptDeadline': module.params.get('attempt_deadline'), u'retryConfig': JobRetryconfig(module.params.get('retry_config', {}), module).to_request(), u'pubsubTarget': JobPubsubtarget(module.params.get('pubsub_target', {}), module).to_request(), u'appEngineHttpTarget': JobAppenginehttptarget(module.params.get('app_engine_http_target', {}), module).to_request(), @@ -772,6 +802,7 @@ def response_to_hash(module, response): u'description': module.params.get('description'), u'schedule': module.params.get('schedule'), u'timeZone': module.params.get('time_zone'), + u'attemptDeadline': module.params.get('attempt_deadline'), u'retryConfig': JobRetryconfig(module.params.get('retry_config', {}), module).to_request(), u'pubsubTarget': JobPubsubtarget(module.params.get('pubsub_target', {}), module).to_request(), u'appEngineHttpTarget': JobAppenginehttptarget(module.params.get('app_engine_http_target', {}), module).to_request(), diff --git a/plugins/modules/gcp_cloudscheduler_job_info.py b/plugins/modules/gcp_cloudscheduler_job_info.py index 51e3848..7208292 100644 --- a/plugins/modules/gcp_cloudscheduler_job_info.py +++ b/plugins/modules/gcp_cloudscheduler_job_info.py @@ -132,6 +132,19 @@ resources: - The value of this field must be a time zone name from the tz database. returned: success type: str + attemptDeadline: + description: + - The deadline for job attempts. If the request handler does not respond by + this deadline then the request is cancelled and the attempt is marked as a + DEADLINE_EXCEEDED failure. The failed attempt can be viewed in execution logs. + Cloud Scheduler will retry the job according to the RetryConfig. + - 'The allowed duration for this deadline is: * For HTTP targets, between 15 + seconds and 30 minutes.' + - "* For App Engine HTTP targets, between 15 seconds and 24 hours." + - 'A duration in seconds with up to nine fractional digits, terminated by ''s''. + Example: "3.5s" .' + returned: success + type: str retryConfig: description: - By default, if a job does not complete successfully, meaning that an acknowledgement diff --git a/tests/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml b/tests/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml index 664ae1d..18773dd 100644 --- a/tests/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml +++ b/tests/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml @@ -20,6 +20,7 @@ schedule: "*/4 * * * *" description: test app engine job time_zone: Europe/London + attempt_deadline: 320s app_engine_http_target: http_method: POST app_engine_routing: @@ -39,6 +40,7 @@ schedule: "*/4 * * * *" description: test app engine job time_zone: Europe/London + attempt_deadline: 320s app_engine_http_target: http_method: POST app_engine_routing: @@ -76,6 +78,7 @@ schedule: "*/4 * * * *" description: test app engine job time_zone: Europe/London + attempt_deadline: 320s app_engine_http_target: http_method: POST app_engine_routing: @@ -100,6 +103,7 @@ schedule: "*/4 * * * *" description: test app engine job time_zone: Europe/London + attempt_deadline: 320s app_engine_http_target: http_method: POST app_engine_routing: @@ -137,6 +141,7 @@ schedule: "*/4 * * * *" description: test app engine job time_zone: Europe/London + attempt_deadline: 320s app_engine_http_target: http_method: POST app_engine_routing: