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.
This commit is contained in:
Pavel Raiskup 2020-06-09 20:23:09 +02:00
parent 3015b75976
commit ea69eebfe6

View file

@ -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"