From aa682fa2c9be9ab75271fbc30abd55a23917b4e6 Mon Sep 17 00:00:00 2001 From: Alexander Komarov Date: Wed, 18 Aug 2021 17:09:46 +0500 Subject: [PATCH 1/3] Add idle_timeout setting to job settings --- awx/main/conf.py | 12 +++++++++++ awx/main/tasks.py | 1 + .../Jobs/JobsDetail/JobsDetail.test.js | 1 + .../screens/Setting/Jobs/JobsEdit/JobsEdit.js | 5 +++++ .../JobsEdit/data.defaultJobSettings.json | 1 + .../shared/data.allSettingOptions.json | 21 +++++++++++++++++++ .../Setting/shared/data.allSettings.json | 1 + .../Setting/shared/data.jobSettings.json | 1 + 8 files changed, 43 insertions(+) diff --git a/awx/main/conf.py b/awx/main/conf.py index d8e8b97206..ed15ea2ddb 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -408,6 +408,18 @@ register( unit=_('seconds'), ) +register( + 'DEFAULT_JOB_IDLE_TIMEOUT', + field_class=fields.IntegerField, + min_value=0, + default=600, + label=_('Default Job Idle Timeout'), + help_text=_('If no output is detected from ansible in this number of seconds the execution will be terminated.'), + category=_('Jobs'), + category_slug='jobs', + unit=_('seconds'), +) + register( 'DEFAULT_INVENTORY_UPDATE_TIMEOUT', field_class=fields.IntegerField, diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 77eef071ae..f61f2847e7 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1365,6 +1365,7 @@ class BaseTask(object): 'envvars': env, 'settings': { 'job_timeout': self.get_instance_timeout(self.instance), + 'idle_timeout': settings.DEFAULT_JOB_IDLE_TIMEOUT, 'suppress_ansible_output': True, }, } diff --git a/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js b/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js index afcdc3c990..0c0b6e019a 100644 --- a/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js +++ b/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js @@ -64,6 +64,7 @@ describe('', () => { ); assertDetail(wrapper, 'Maximum Scheduled Jobs', '10'); assertDetail(wrapper, 'Default Job Timeout', '0 seconds'); + assertDetail(wrapper, 'Default Job Idle Timeout', '600 seconds'); assertDetail(wrapper, 'Default Inventory Update Timeout', '0 seconds'); assertDetail(wrapper, 'Default Project Update Timeout', '0 seconds'); assertDetail(wrapper, 'Per-Host Ansible Fact Cache Timeout', '0 seconds'); diff --git a/awx/ui/src/screens/Setting/Jobs/JobsEdit/JobsEdit.js b/awx/ui/src/screens/Setting/Jobs/JobsEdit/JobsEdit.js index 734b78597f..56b35341a9 100644 --- a/awx/ui/src/screens/Setting/Jobs/JobsEdit/JobsEdit.js +++ b/awx/ui/src/screens/Setting/Jobs/JobsEdit/JobsEdit.js @@ -137,6 +137,11 @@ function JobsEdit() { config={jobs.DEFAULT_JOB_TIMEOUT} type="number" /> + Date: Thu, 19 Aug 2021 14:48:11 +0500 Subject: [PATCH 2/3] Set default value is 0 for idle_timeout --- awx/main/conf.py | 7 +++++-- awx/main/tasks.py | 4 +++- .../src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js | 2 +- .../Setting/Jobs/JobsEdit/data.defaultJobSettings.json | 2 +- .../src/screens/Setting/shared/data.allSettingOptions.json | 6 +++--- awx/ui/src/screens/Setting/shared/data.allSettings.json | 2 +- awx/ui/src/screens/Setting/shared/data.jobSettings.json | 2 +- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/awx/main/conf.py b/awx/main/conf.py index ed15ea2ddb..cfe7ebe80d 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -412,9 +412,12 @@ register( 'DEFAULT_JOB_IDLE_TIMEOUT', field_class=fields.IntegerField, min_value=0, - default=600, + default=0, label=_('Default Job Idle Timeout'), - help_text=_('If no output is detected from ansible in this number of seconds the execution will be terminated.'), + help_text=_( + 'If no output is detected from ansible in this number of seconds the execution will be terminated. ' + 'Use value of 0 to used default idle_timeout is 600s.' + ), category=_('Jobs'), category_slug='jobs', unit=_('seconds'), diff --git a/awx/main/tasks.py b/awx/main/tasks.py index f61f2847e7..83b7d9bd69 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1365,11 +1365,13 @@ class BaseTask(object): 'envvars': env, 'settings': { 'job_timeout': self.get_instance_timeout(self.instance), - 'idle_timeout': settings.DEFAULT_JOB_IDLE_TIMEOUT, 'suppress_ansible_output': True, }, } + if settings.DEFAULT_JOB_IDLE_TIMEOUT > 0: + params['settings']['idle_timeout'] = settings.DEFAULT_JOB_IDLE_TIMEOUT + if isinstance(self.instance, AdHocCommand): params['module'] = self.build_module_name(self.instance) params['module_args'] = self.build_module_args(self.instance) diff --git a/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js b/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js index 0c0b6e019a..9b0dda4233 100644 --- a/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js +++ b/awx/ui/src/screens/Setting/Jobs/JobsDetail/JobsDetail.test.js @@ -64,7 +64,7 @@ describe('', () => { ); assertDetail(wrapper, 'Maximum Scheduled Jobs', '10'); assertDetail(wrapper, 'Default Job Timeout', '0 seconds'); - assertDetail(wrapper, 'Default Job Idle Timeout', '600 seconds'); + assertDetail(wrapper, 'Default Job Idle Timeout', '0 seconds'); assertDetail(wrapper, 'Default Inventory Update Timeout', '0 seconds'); assertDetail(wrapper, 'Default Project Update Timeout', '0 seconds'); assertDetail(wrapper, 'Per-Host Ansible Fact Cache Timeout', '0 seconds'); diff --git a/awx/ui/src/screens/Setting/Jobs/JobsEdit/data.defaultJobSettings.json b/awx/ui/src/screens/Setting/Jobs/JobsEdit/data.defaultJobSettings.json index 9ee56e2d45..749249494a 100644 --- a/awx/ui/src/screens/Setting/Jobs/JobsEdit/data.defaultJobSettings.json +++ b/awx/ui/src/screens/Setting/Jobs/JobsEdit/data.defaultJobSettings.json @@ -30,7 +30,7 @@ "AWX_TASK_ENV": {}, "DEFAULT_INVENTORY_UPDATE_TIMEOUT": 0, "DEFAULT_JOB_TIMEOUT": 0, - "DEFAULT_JOB_IDLE_TIMEOUT": 600, + "DEFAULT_JOB_IDLE_TIMEOUT": 0, "DEFAULT_PROJECT_UPDATE_TIMEOUT": 0, "GALAXY_IGNORE_CERTS": false, "MAX_FORKS": 200, diff --git a/awx/ui/src/screens/Setting/shared/data.allSettingOptions.json b/awx/ui/src/screens/Setting/shared/data.allSettingOptions.json index fb56892906..ff176e0661 100644 --- a/awx/ui/src/screens/Setting/shared/data.allSettingOptions.json +++ b/awx/ui/src/screens/Setting/shared/data.allSettingOptions.json @@ -344,12 +344,12 @@ "type": "integer", "required": false, "label": "Default Job Idle Timeout", - "help_text": "If no output is detected from ansible in this number of seconds the execution will be terminated.", + "help_text": "If no output is detected from ansible in this number of seconds the execution will be terminated. Use value of 0 to used default idle_timeout is 600s.", "min_value": 0, "category": "Jobs", "category_slug": "jobs", "unit": "seconds", - "default": 600 + "default": 0 }, "DEFAULT_INVENTORY_UPDATE_TIMEOUT": { "type": "integer", @@ -4001,7 +4001,7 @@ "DEFAULT_JOB_IDLE_TIMEOUT": { "type": "integer", "label": "Default Job Idle Timeout", - "help_text": "If no output is detected from ansible in this number of seconds the execution will be terminated.", + "help_text": "If no output is detected from ansible in this number of seconds the execution will be terminated. Use value of 0 to used default idle_timeout is 600s.", "min_value": 0, "category": "Jobs", "category_slug": "jobs", diff --git a/awx/ui/src/screens/Setting/shared/data.allSettings.json b/awx/ui/src/screens/Setting/shared/data.allSettings.json index 21ef240e2d..c33a93eccf 100644 --- a/awx/ui/src/screens/Setting/shared/data.allSettings.json +++ b/awx/ui/src/screens/Setting/shared/data.allSettings.json @@ -49,7 +49,7 @@ "SCHEDULE_MAX_JOBS":10, "AWX_ANSIBLE_CALLBACK_PLUGINS":[], "DEFAULT_JOB_TIMEOUT":0, - "DEFAULT_JOB_IDLE_TIMEOUT":600, + "DEFAULT_JOB_IDLE_TIMEOUT":0, "DEFAULT_INVENTORY_UPDATE_TIMEOUT":0, "DEFAULT_PROJECT_UPDATE_TIMEOUT":0, "ANSIBLE_FACT_CACHE_TIMEOUT":0, diff --git a/awx/ui/src/screens/Setting/shared/data.jobSettings.json b/awx/ui/src/screens/Setting/shared/data.jobSettings.json index 9ac0a27228..1815cc12b7 100644 --- a/awx/ui/src/screens/Setting/shared/data.jobSettings.json +++ b/awx/ui/src/screens/Setting/shared/data.jobSettings.json @@ -17,7 +17,7 @@ "SCHEDULE_MAX_JOBS": 10, "AWX_ANSIBLE_CALLBACK_PLUGINS": [], "DEFAULT_JOB_TIMEOUT": 0, - "DEFAULT_JOB_IDLE_TIMEOUT": 600, + "DEFAULT_JOB_IDLE_TIMEOUT": 0, "DEFAULT_INVENTORY_UPDATE_TIMEOUT": 0, "DEFAULT_PROJECT_UPDATE_TIMEOUT": 0, "ANSIBLE_FACT_CACHE_TIMEOUT": 0, From 899d36b2c9e4eea563ed6cafe84c8e72dbb2b30a Mon Sep 17 00:00:00 2001 From: Alexander Komarov Date: Thu, 19 Aug 2021 15:20:52 +0500 Subject: [PATCH 3/3] Fix tests --- awx/main/tasks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 83b7d9bd69..6588ef630a 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -1369,8 +1369,9 @@ class BaseTask(object): }, } - if settings.DEFAULT_JOB_IDLE_TIMEOUT > 0: - params['settings']['idle_timeout'] = settings.DEFAULT_JOB_IDLE_TIMEOUT + idle_timeout = getattr(settings, 'DEFAULT_JOB_IDLE_TIMEOUT', 0) + if idle_timeout > 0: + params['settings']['idle_timeout'] = idle_timeout if isinstance(self.instance, AdHocCommand): params['module'] = self.build_module_name(self.instance)