Compile SELinux module via async

This patch adjusts the SELinux rule compile task to run with async.
Some CI jobs are CPU-bound and this compile step can take 30-45
seconds to complete on slower machines.

Change-Id: Ia20b8cc00ad3bad6d6ccf9cd995d0ef24f2090a0
(cherry picked from commit 79e5e571de)
This commit is contained in:
Major Hayden 2017-08-23 11:00:09 -05:00
parent 412884fd9d
commit fc561e5ace
2 changed files with 16 additions and 6 deletions

View File

@ -13,13 +13,13 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: Create directory for compiling SELinux rule - name: Create directory for compiling SELinux policy
file: file:
path: "/tmp/lxc-attach-selinux/" path: "/tmp/lxc-attach-selinux/"
state: 'directory' state: 'directory'
mode: '0755' mode: '0755'
- name: Drop SELinux config - name: Deploy SELinux type enforcement file
copy: copy:
src: "lxc-attach.te" src: "lxc-attach.te"
dest: "/tmp/lxc-attach-selinux/lxc-attach.te" dest: "/tmp/lxc-attach-selinux/lxc-attach.te"
@ -28,13 +28,13 @@
mode: "0755" mode: "0755"
- name: Compile and load SELinux module - name: Compile and load SELinux module
command: '{{ item }}' shell: 'make -f /usr/share/selinux/devel/Makefile && semodule -i /tmp/lxc-attach-selinux/lxc-attach.pp'
args: args:
creates: '/etc/selinux/targeted/active/modules/400/lxc-attach/cil' creates: '/etc/selinux/targeted/active/modules/400/lxc-attach/cil'
chdir: "/tmp/lxc-attach-selinux/" chdir: "/tmp/lxc-attach-selinux/"
with_items: register: compile_selinux_async
- make -f /usr/share/selinux/devel/Makefile async: 90
- semodule -i /tmp/lxc-attach-selinux/lxc-attach.pp poll: 0
- name: Check if /openstack/log exists - name: Check if /openstack/log exists
stat: stat:

View File

@ -81,3 +81,13 @@
- name: Flush handlers - name: Flush handlers
meta: flush_handlers meta: flush_handlers
- name: Ensure SELinux module compile has finished
async_status:
jid: "{{ compile_selinux_async.ansible_job_id }}"
register: _compile_selinux_async
until: _compile_selinux_async.finished
retries: 30
when:
- compile_selinux_async is defined
- not compile_selinux_async | skipped