8000 Use ansible-runner change to get periodic keep-alive messages in K8S by AlanCoding · Pull Request #13608 · ansible/awx · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Use ansible-runner change to get periodic keep-alive messages in K8S #13608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions awx/main/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,16 @@
placeholder={'HTTP_PROXY': 'myproxy.local:8080'},
)

register(
'AWX_RUNNER_KEEPALIVE_SECONDS',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rename this to something about K8S_?

field_class=fields.IntegerField,
label=_('K8S Ansible Runner Keep-Alive Message Interval'),
help_text=_('Only applies to jobs running in a Container Group. If not 0, send a message every so-many seconds to keep connection open.'),
category=_('Jobs'),
category_slug='jobs',
placeholder=240, # intended to be under common 5 minute idle timeout
)

register(
'GALAXY_TASK_ENV',
field_class=fields.KeyValueField,
Expand Down
2 changes: 2 additions & 0 deletions awx/main/tasks/callback.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def event_handler(self, event_data):
# which generate job events from two 'streams':
# ansible-inventory and the awx.main.commands.inventory_import
# logger
if event_data.get('event') == 'keepalive':
return
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From discussion with @TheRealHaoLiu, we are unlikely to need this, but I would prefer to keep it in anyway. Maybe leave a comment that it should be dead code.


if event_data.get(self.event_data_key, None):
if self.event_data_key != 'job_id':
Expand Down
4 changes: 4 additions & 0 deletions awx/main/tasks/receptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,10 @@ def pod_definition(self):
pod_spec['spec']['containers'][0]['image'] = ee.image
pod_spec['spec']['containers'][0]['args'] = ['ansible-runner', 'worker', '--private-data-dir=/runner']

if settings.AWX_RUNNER_KEEPALIVE_SECONDS:
pod_spec['spec']['containers'][0].setdefault('env', [])
pod_spec['spec']['containers'][0]['env'].append({'name': 'ANSIBLE_RUNNER_KEEPALIVE_SECONDS', 'value': str(settings.AWX_RUNNER_KEEPALIVE_SECONDS)})

# Enforce EE Pull Policy
pull_options = {"always": "Always", "missing": "IfNotPresent", "never": "Never"}
if self.task and self.task.instance.execution_environment:
Expand Down
5 changes: 5 additions & 0 deletions awx/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,11 @@
# Allow ansible-runner to save ansible output (may cause performance issues)
AWX_RUNNER_SUPPRESS_OUTPUT_FILE = True

# https://github.com/ansible/ansible-runner/pull/1191/files
# Interval in seconds between the last message and keep-alive messages that
# ansible-runner will send
AWX_RUNNER_KEEPALIVE_SECONDS = 0

# Delete completed work units in receptor
RECEPTOR_RELEASE_WORK = True

Expand Down
5 changes: 5 additions & 0 deletions awx/ui/src/screens/Setting/Jobs/JobsEdit/JobsEdit.js
8000
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ function JobsEdit() {
type={options?.SCHEDULE_MAX_JOBS ? 'number' : undefined}
isRequired={Boolean(options?.SCHEDULE_MAX_JOBS)}
/>
<InputField
name="AWX_RUNNER_KEEPALIVE_SECONDS"
config={jobs.AWX_RUNNER_KEEPALIVE_SECONDS}
type="number"
/>
<InputField
name="DEFAULT_JOB_TIMEOUT"
config={jobs.DEFAULT_JOB_TIMEOUT}
Expand Down
19 changes: 19 additions & 0 deletions awx/ui/src/screens/Setting/shared/data.allSettingOptions.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@
"category_slug": "jobs",
"default": 10
},
"AWX_RUNNER_KEEPALIVE_SECONDS": {
"type": "integer",
"required": true,
"label": "K8S Ansible Runner Keep-Alive Message Interval",
"help_text": "Only applies to K8S deployments and container_group jobs. If not 0, send a message every so-many seconds to keep connection open.",
"category": "Jobs",
"category_slug": "jobs",
"placeholder": 240,
"default": 0
},
"AWX_ANSIBLE_CALLBACK_PLUGINS": {
"type": "list",
"required": false,
Expand Down Expand Up @@ -4098,6 +4108,15 @@
"category_slug": "jobs",
"defined_in_file": false
},
"AWX_RUNNER_KEEPALIVE_SECONDS": {
"type": "integer",
"label": "K8S Ansible Runner Keep-Alive Message Interval",
"help_text": "Only applies to K8S deployments and container_group jobs. If not 0, send a message every so-many seconds to keep connection open.",
"category": "Jobs",
"category_slug": "jobs",
"placeholder": 240,
"default": 0
},
"AWX_ANSIBLE_CALLBACK_PLUGINS": {
"type": "list",
"label": "Ansible Callback Plugins",
Expand Down
1 change: 1 addition & 0 deletions awx/ui/src/screens/Setting/shared/data.allSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"STDOUT_MAX_BYTES_DISPLAY":1048576,
"EVENT_STDOUT_MAX_BYTES_DISPLAY":1024,
"SCHEDULE_MAX_JOBS":10,
"AWX_RUNNER_KEEPALIVE_SECONDS": 0,
"AWX_ANSIBLE_CALLBACK_PLUGINS":[],
"DEFAULT_JOB_TIMEOUT":0,
"DEFAULT_JOB_IDLE_TIMEOUT":0,
Expand Down
1 change: 1 addition & 0 deletions awx/ui/src/screens/Setting/shared/data.jobSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"STDOUT_MAX_BYTES_DISPLAY": 1048576,
"EVENT_STDOUT_MAX_BYTES_DISPLAY": 1024,
"SCHEDULE_MAX_JOBS": 10,
"AWX_RUNNER_KEEPALIVE_SECONDS": 0,
"AWX_ANSIBLE_CALLBACK_PLUGINS": [],
"DEFAULT_JOB_TIMEOUT": 0,
"DEFAULT_JOB_IDLE_TIMEOUT": 0,
Expand Down
0