Make long-running tasks use async

This patch makes two long-running Horizon tasks use async:

  - compressing static files
  - compiling messages for translation

Combined, these steps take anywhere from 60-120 seconds to complete,
depending on the CI environment.

Change-Id: Ibee0a0f5ebfe575d1e336c2e98322bc0a85a7af7
(cherry picked from commit 1ed153273d)
This commit is contained in:
Major Hayden 2017-02-21 10:50:39 -05:00 committed by Jesse Pretorius (odyssey4me)
parent a3151e5609
commit ae6cf338a4
2 changed files with 30 additions and 0 deletions

View File

@ -159,6 +159,9 @@
with_items:
- horizon
- openstack_dashboard
register: async_compile_messages
async: 600
poll: 0
- name: Collect and compress static files
command: "{{ item }}"
@ -169,3 +172,6 @@
- "{{ horizon_bin }}/horizon-manage.py collectstatic --noinput"
- "{{ horizon_bin }}/horizon-manage.py compress --force"
notify: Restart apache2
register: async_compress_static_files
async: 600
poll: 0

View File

@ -68,6 +68,30 @@
tags:
- horizon-config
- name: Ensure messages are compiled for translation
async_status:
jid: "{{ item.ansible_job_id }}"
register: async_compile_messages_check
until: async_compile_messages_check.finished
retries: 300
with_items:
- "{{ async_compile_messages.results }}"
# NOTE(mhayden): The async_status check here must be done as the horizon user
# since the original task ran as that user. This task will fail if it is run
# as root because the async status file is within the horizon user's home
# directory, not root's home directory.
- name: Ensure static files are collected and compressed
async_status:
jid: "{{ item.ansible_job_id }}"
become: yes
become_user: "{{ horizon_system_user_name }}"
register: async_compress_static_files_check
until: async_compress_static_files_check.finished
retries: 300
with_items:
- "{{ async_compress_static_files.results }}"
- include: horizon_apache.yml
tags:
- horizon-config