From 08405d960f1d7e479d89b8f6c53112860e483e08 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Wed, 28 Jun 2023 14:36:42 +0200 Subject: [PATCH] Koschei: Add full update playbook --- playbooks/manual/upgrade/koschei-full.yml | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 playbooks/manual/upgrade/koschei-full.yml diff --git a/playbooks/manual/upgrade/koschei-full.yml b/playbooks/manual/upgrade/koschei-full.yml new file mode 100644 index 0000000000..1235a52e3a --- /dev/null +++ b/playbooks/manual/upgrade/koschei-full.yml @@ -0,0 +1,54 @@ +# This playbook can be used to update running Koschei instance to +# latest upstream version. It causes user-visible downtime, but +# unlike koschei-rolling.yml, it works even in case when there are +# database migrations to apply. + +- name: Perform full Koschei update + hosts: os_control[0]:os_control_stg[0] + user: root + vars_files: + - /srv/web/infra/ansible/vars/global.yml + - /srv/private/ansible/vars.yml + - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml + - /srv/web/infra/ansible/roles/openshift-apps/koschei/vars/main.yml + - /srv/web/infra/ansible/roles/openshift-apps/koschei/vars/{{ env }}.yml + handlers: + - import_tasks: "{{ handlers_path }}/restart_services.yml" + + tasks: + - name: Stop backend services + shell: oc -n koschei scale dc/{{item.name}} --replicas=0 + with_items: "{{ koschei_backend_services }}" + loop_control: + label: "{{ item.name }}" + + - name: Stop frontend + shell: oc -n koschei scale dc/frontend --replicas=0 + + - name: Import upstream image into OpenShift + include_role: name=openshift/import-image + vars: + imagestreamname: koschei + + - name: Run database migrations + include_role: name=openshift-apps/koschei/job + vars: + name: db-migrate + command: "koschei-admin alembic upgrade head" + + # Since everything is stopped and users are seeing downtime anyway, + # we may as well want to vacuum the DB to improve performance. + - name: Vacuum database + include_role: name=openshift-apps/koschei/job + vars: + name: db-vacuum + command: "koschei-admin psql <<<'VACUUM FULL ANALYZE'" + + - name: Start frontend + shell: oc -n koschei scale dc/frontend --replicas={{koschei_frontend_replicas}} + + - name: Start backend services + shell: oc -n koschei scale dc/{{item.name}} --replicas=1 + with_items: "{{ koschei_backend_services }}" + loop_control: + label: "{{ item.name }}"