From ea69eebfe60ce1a8363cae4131c5d0ec4ef73091 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Tue, 9 Jun 2020 20:23:09 +0200 Subject: [PATCH] copr-fe: make copr-frontend-upgrade.yml more usable Without shutting httpd down, sometimes - when there's high enough load - post scriptlet of copr-frontend takes too long to finish (restarging httpd, gently waiting for existing connections). But that makes the outage window larger as httpd doesn't accept the new connections when shutting down. So automatize (forced) shutdown of httpd first (when there's existing frontend update) -> upgrade the package -> run the migrations -> and make httpd started again. --- .../manual/copr/copr-frontend-upgrade.yml | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/playbooks/manual/copr/copr-frontend-upgrade.yml b/playbooks/manual/copr/copr-frontend-upgrade.yml index d61a3af36e..dbf468fff4 100644 --- a/playbooks/manual/copr/copr-frontend-upgrade.yml +++ b/playbooks/manual/copr/copr-frontend-upgrade.yml @@ -16,6 +16,24 @@ - name: Generic upgrade tasks for copr servers import_tasks: _generic_tasks.yml + - name: Check for copr-frontend update + shell: dnf clean expire-cache ; dnf check-update copr-frontend + register: frontend_has_update + changed_when: "frontend_has_update.rc != 0" + failed_when: false + + - name: Check if HTTPD is running + shell: systemctl status httpd + register: httpd_running + changed_when: "httpd_running.rc != 0" + failed_when: false + + - name: Shutdown httpd to allow running DB migrations + shell: timeout 20 systemctl stop httpd || systemctl kill httpd + when: + - frontend_has_update.changed + - httpd_running.changed + - name: Upgrade copr-frontend packages dnf: state: latest @@ -24,12 +42,6 @@ - copr-frontend-fedora - copr-selinux - python3-copr-common - update_cache: true - - - name: cache the new package version - copy: content="{{ ansible_facts.packages['copr-frontend'][0].version }}" - dest="{{ cache_file }}" - register: version_file - name: upgrade db to head command: alembic-3 upgrade head @@ -37,7 +49,10 @@ become_user: copr-fe args: chdir: /usr/share/copr/coprs_frontend/ - when: version_file.changed + when: frontend_has_update.changed + + - name: make httpd started + service: name=httpd state=started handlers: - import_tasks: "{{ handlers_path }}/restart_services.yml"