From ac35a48d8cc6ef4207671ccce3bf870f7552e4b5 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: Tue, 24 May 2016 11:38:46 -0700 Subject: [PATCH] openqa/server: set up a cron job to do createhdds daily instead of just relying on it getting run when we do an ansible run, since that's intermittent and it's annoying when you want to do an ansible run and it sits there for hours creating disk images. This way we'll know they'll get updated regularly and ansible runs should never get blocked on image creation, though we still do it in the ansible plays just in case (and for initial deployment). This should now be safe, with the recent changes to make it time out gracefully and run atomically. We also use withlock to make sure we don't stack jobs. --- roles/openqa/server/files/createhdds | 4 ++++ roles/openqa/server/tasks/main.yml | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 roles/openqa/server/files/createhdds diff --git a/roles/openqa/server/files/createhdds b/roles/openqa/server/files/createhdds new file mode 100644 index 0000000000..1ba6bd8334 --- /dev/null +++ b/roles/openqa/server/files/createhdds @@ -0,0 +1,4 @@ +#!/bin/sh + +cd /var/lib/openqa/share/factory/hdd +LIBGUESTFS_BACKEND=direct withlock /var/lock/createhdds.lock /root/openqa_fedora_tools/tools/createhdds.py all --clean diff --git a/roles/openqa/server/tasks/main.yml b/roles/openqa/server/tasks/main.yml index 0cb72c9eb8..b7135a123b 100644 --- a/roles/openqa/server/tasks/main.yml +++ b/roles/openqa/server/tasks/main.yml @@ -89,6 +89,7 @@ - python3-fedfind - python3-libguestfs - python3-pexpect + - withlock tags: - packages @@ -113,6 +114,9 @@ - /var/lib/openqa/share/factory/repo - /var/lib/openqa/share/factory/other +- name: Set up createhdds cron job + copy: src=createhdds dest=/etc/cron.daily/createhdds owner=root group=root mode=0755 + - name: Check if any hard disk images need (re)building command: "/root/openqa_fedora_tools/tools/createhdds.py check" args: @@ -123,11 +127,7 @@ always_run: true - name: Create hard disk images (this may take a long time!) - command: "/root/openqa_fedora_tools/tools/createhdds.py all --clean" - args: - chdir: /var/lib/openqa/share/factory/hdd/ - environment: - LIBGUESTFS_BACKEND: direct + command: "/etc/cron.daily/createhdds" when: "diskcheck.rc > 0" - name: Create exports file