diff --git a/build/packages/rpm/server/SPECS/grafana-db-migrator.spec b/build/packages/rpm/server/SPECS/grafana-db-migrator.spec index 70de6bd075..c3f074740c 100644 --- a/build/packages/rpm/server/SPECS/grafana-db-migrator.spec +++ b/build/packages/rpm/server/SPECS/grafana-db-migrator.spec @@ -1,10 +1,10 @@ %undefine _missing_build_ids_terminate_build -%global release_hash 63e4bfdb7dd7162e238531c794f4ddef83173158 +%global release_hash 27b37c412e257bd8a5bcdbcaf52befa3fe555a9d Name: grafana-db-migrator -Version: 1.0.7 -Release: 1%{?dist} +Version: 1.0.8 +Release: 2%{?dist} Summary: A tool for Grafana database migration License: MIT URL: https://github.com/percona/grafana-db-migrator @@ -30,6 +30,9 @@ install -m 755 dist/grafana-db-migrator %{buildroot}%{_sbindir}/ %{_sbindir}/grafana-db-migrator %changelog +* Fri Oct 13 2023 Nurlan Moldomurov - 1.0.8-2 +- Fix issue with hexed values and folder fixes. + * Mon Feb 13 2023 Nikita Beletskii <2nikita.b@gmail.com> - 1.0.7-1 - Fix issue with convert_from() diff --git a/build/scripts/build-server-rpm b/build/scripts/build-server-rpm index 0ceccebb23..58f619ffda 100755 --- a/build/scripts/build-server-rpm +++ b/build/scripts/build-server-rpm @@ -148,6 +148,9 @@ build() { s3://pmm-build-cache/RELEASE/${rpmbuild_dist}/${spec_name}-${rpm_version} \ || : fi + + cp ${rpms_dir}/${spec_name}-${rpm_version}/*/*.rpm ${rpms_dir} + fi } diff --git a/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml b/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml index 2476b13d68..c3cc50d5f0 100644 --- a/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml +++ b/update/ansible/playbook/tasks/roles/initialization/tasks/main.yml @@ -34,6 +34,11 @@ debug: msg: "Current version: {{ pmm_current_version }} Image Version: {{ pmm_image_version }}" +# We use current_version_file['failed'] because we don't want to run this on creating container +# and we use pmm_current_version is version(pmm_image_version, '>=') to run it only if upgrade is required +- name: Determine type of upgrade + set_fact: + docker_upgrade: not ui_upgrade and current_version_file['failed'] == false and not pmm_current_version is version(pmm_image_version, '>=') # We use current_version_file['failed'] because we don't want to run this on creating container # and we use pmm_current_version is version(pmm_image_version, '>=') to run it only if upgrade is required @@ -42,7 +47,7 @@ src: maintenance.html dest: /usr/share/pmm-server/maintenance/ mode: 0644 - when: not ui_upgrade and current_version_file['failed'] == false and not pmm_current_version is version(pmm_image_version, '>=') + when: docker_upgrade # PMM-10858 - In certain environments, including AWS EC2, some of the # EPEL repository mirrors do not respond within the time limit defined @@ -60,11 +65,6 @@ become: true changed_when: True -- name: Check if we need an update or not - include_role: - name: dashboards_upgrade - when: not pmm_current_version is version(pmm_image_version, '>=') - - name: Create backup directory file: path: /srv/backup @@ -159,7 +159,15 @@ tags: - skip_ansible_lint # '503 Tasks that run when changed should likely be handlers'. when: is_database_sqlite.stat.exists + when: docker_upgrade +- name: Check if we need an update or not + include_role: + name: dashboards_upgrade + when: not pmm_current_version is version(pmm_image_version, '>=') + +- name: Finalization + block: - name: Wait for PMM to be ready ansible.builtin.uri: url: "http://127.0.0.1:7772/v1/readyz" @@ -173,6 +181,6 @@ state: absent path: /usr/share/pmm-server/maintenance/maintenance.html # We use current_version_file['failed'] because we don't want to run this on creating container - when: not ui_upgrade and current_version_file['failed'] == false and not pmm_current_version is version(pmm_image_version, '>=') + when: docker_upgrade diff --git a/update/ansible/playbook/tasks/roles/sqlite-to-postgres/tasks/main.yml b/update/ansible/playbook/tasks/roles/sqlite-to-postgres/tasks/main.yml index 490ce26c7f..5c12040c39 100644 --- a/update/ansible/playbook/tasks/roles/sqlite-to-postgres/tasks/main.yml +++ b/update/ansible/playbook/tasks/roles/sqlite-to-postgres/tasks/main.yml @@ -22,6 +22,39 @@ name: 'grafana' state: stopped +- name: Drop grafana database from postgres EL7 + postgresql_query: + db: postgres + query: DROP DATABASE grafana WITH (FORCE); + when: + - ansible_distribution == "CentOS" + - ansible_distribution_major_version == "7" + - not ansible_check_mode + +- name: Drop grafana database from postgres EL9 + postgresql_db: + name: grafana + state: absent + force: yes + when: + - ansible_distribution == 'OracleLinux' or ansible_distribution == 'AlmaLinux' + - ansible_distribution_major_version == '9' + +- name: Create grafana database in postgres + postgresql_db: + name: grafana + state: present + +- name: Create grafana user in postgres + postgresql_user: + db: grafana + name: grafana + password: grafana + priv: 'ALL' + expires: infinity + state: present + when: not ansible_check_mode + - name: Create backup for SQLite Grafana database copy: src: /srv/grafana/grafana.db @@ -105,6 +138,12 @@ register: migrator_output changed_when: "'All done' in migrator_output.stdout" +- name: copy the output of grafana-db-migrator to file + copy: + content: "{{ migrator_output.stdout }}" + dest: "/srv/logs/grafana-db-migrator.log" + when: not ansible_check_mode + - name: Enable provisioning after change database ini_file: dest: /etc/grafana/grafana.ini @@ -126,6 +165,13 @@ register: migrator_output changed_when: "'All done' in migrator_output.stdout" +- name: Copy the output of grafana-db-migrator to file + ansible.builtin.blockinfile: + dest: /srv/logs/grafana-db-migrator.log + block: "{{ migrator_output.stdout }}" + backup: yes + when: not ansible_check_mode + - name: Remove SQLite Grafana database file: path: /srv/grafana/grafana.db