From ae6cf338a4a126236918a3c77467ca5132e3b79e Mon Sep 17 00:00:00 2001 From: Major Hayden Date: Tue, 21 Feb 2017 10:50:39 -0500 Subject: [PATCH] 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 1ed153273d89c93de0ee9483e2687c24b7f3be33) --- tasks/horizon_post_install.yml | 6 ++++++ tasks/main.yml | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tasks/horizon_post_install.yml b/tasks/horizon_post_install.yml index b7bda1f0..17dd23eb 100644 --- a/tasks/horizon_post_install.yml +++ b/tasks/horizon_post_install.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index dfc17237..e0d0b839 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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