From 8d795f7c8fbdd72c2d2b47d57184220ee3bdee8a Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Sat, 23 Mar 2024 20:12:15 +0300 Subject: [PATCH 1/2] PMM-12641 Fix the dashboard upgrade This fixes a bug where, due to a wrong ansible formula, PMM would upgrade the dashboards no matter what :) --- .../roles/initialization/tasks/main.yml | 87 ++++++++++--------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/build/ansible/roles/initialization/tasks/main.yml b/build/ansible/roles/initialization/tasks/main.yml index be42baf2e8..a9265f55ba 100644 --- a/build/ansible/roles/initialization/tasks/main.yml +++ b/build/ansible/roles/initialization/tasks/main.yml @@ -27,56 +27,61 @@ - name: Set need_upgrade fact set_fact: - need_upgrade: not pmm_current_version is version(pmm_image_version, '>=') + need_upgrade: "{{ pmm_current_version is version(pmm_image_version, '<') }}" - name: Print current PMM and image versions debug: msg: "Current version: {{ pmm_current_version }} Image Version: {{ pmm_image_version }}" -- name: Enable maintenance mode before upgrade - copy: - src: maintenance.html - dest: /usr/share/pmm-server/maintenance/ - owner: pmm - group: pmm - mode: 0644 +- name: Print need_upgrade fact + debug: + msg: "Need upgrade: {{ need_upgrade }}" -- name: Upgrade dashboards - include_role: - name: dashboards - when: need_upgrade +- name: Perform upgrade tasks + block: + - name: Enable maintenance mode before upgrade + copy: + src: maintenance.html + dest: /usr/share/pmm-server/maintenance/ + owner: pmm + group: pmm + mode: 0644 + + - name: Upgrade dashboards + include_role: + name: dashboards + + - name: Copy file with image version + copy: + src: /usr/share/percona-dashboards/VERSION + dest: /srv/grafana/PERCONA_DASHBOARDS_VERSION + owner: pmm + group: pmm + mode: 0644 + remote_src: yes + + - name: Create a backup directory + file: + path: /srv/backup + state: directory + owner: pmm + group: pmm + mode: 0775 -- name: Copy file with image version - copy: - src: /usr/share/percona-dashboards/VERSION - dest: /srv/grafana/PERCONA_DASHBOARDS_VERSION - owner: pmm - group: pmm - mode: 0644 - remote_src: yes + - name: Wait for PMM to be ready + ansible.builtin.uri: + url: "http://127.0.0.1:7772/v1/readyz" + status_code: 200 + method: GET + retries: 20 + delay: 5 + + - name: Disable maintenance mode + file: + state: absent + path: /usr/share/pmm-server/maintenance/maintenance.html when: need_upgrade -- name: Create a backup directory - file: - path: /srv/backup - state: directory - owner: pmm - group: pmm - mode: 0775 - # Note: we want to leave this for some time until we achieve stable builds - name: Output pmm-managed logs shell: sleep 10 && tail -n 300 /srv/logs/pmm-managed.log - -- name: Wait for PMM to be ready - ansible.builtin.uri: - url: "http://127.0.0.1:7772/v1/readyz" - status_code: 200 - method: GET - retries: 20 - delay: 5 - -- name: Disable maintenance mode - file: - state: absent - path: /usr/share/pmm-server/maintenance/maintenance.html From 519525a9818f9e448b2b108f0f08e0aa6a6c38b6 Mon Sep 17 00:00:00 2001 From: Alex Demidoff Date: Mon, 25 Mar 2024 15:11:00 +0300 Subject: [PATCH 2/2] PMM-12641 follow up on review --- build/ansible/roles/initialization/tasks/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/ansible/roles/initialization/tasks/main.yml b/build/ansible/roles/initialization/tasks/main.yml index a9265f55ba..4cb85312f7 100644 --- a/build/ansible/roles/initialization/tasks/main.yml +++ b/build/ansible/roles/initialization/tasks/main.yml @@ -68,6 +68,10 @@ group: pmm mode: 0775 + # Note: we want to leave this for some time until we achieve stable builds + - name: Output pmm-managed logs + shell: sleep 10 && tail -n 300 /srv/logs/pmm-managed.log + - name: Wait for PMM to be ready ansible.builtin.uri: url: "http://127.0.0.1:7772/v1/readyz" @@ -81,7 +85,3 @@ state: absent path: /usr/share/pmm-server/maintenance/maintenance.html when: need_upgrade - -# Note: we want to leave this for some time until we achieve stable builds -- name: Output pmm-managed logs - shell: sleep 10 && tail -n 300 /srv/logs/pmm-managed.log