Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Check for background migration on GitLab update only #131

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,39 @@
update_cache: true
check_mode: false

- name: Ensure gitlab-rails file exist
- name: Check if VERSION file exists
ansible.builtin.stat:
path: "/usr/bin/gitlab-rails"
register: file
path: "/var/opt/gitlab/gitlab-rails/VERSION"
register: gitlab_version_file

- name: Wait until all previous background migrations are processed.
become: yes
ansible.builtin.command:
cmd: gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
register: remaining
until: remaining.stdout == "0"
retries: 10
delay: 10
check_mode: no
changed_when: remaining.rc != 0
- name: Wait for background migrations on primary node
when:
- file.stat.exists
- file.stat.executable
- gitlab_is_primary is defined
- gitlab_is_primary
- gitlab_version_file.stat.exists
- gitlab_rails_binary.stat.exists
- gitlab_rails_binary.stat.executable
tobiashuste marked this conversation as resolved.
Show resolved Hide resolved
block:
- name: Get the currently installed GitLab version
ansible.builtin.slurp:
path: "/var/opt/gitlab/gitlab-rails/VERSION"
register: gitlab_version_base64

- name: Set fact about installed GitLab version
ansible.builtin.set_fact:
gitlab_installed_version: "{{ gitlab_version_base64['content'] | b64decode }}"
check_mode: no

- name: Wait until all previous background migrations are processed.
become: yes
ansible.builtin.command:
cmd: gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
register: remaining
until: remaining.stdout == "0"
retries: 10
delay: 10
check_mode: no
changed_when: false
when: gitlab_version == '' or gitlab_installed_version is version(gitlab_version, operator='lt', strict=True)
Normo marked this conversation as resolved.
Show resolved Hide resolved

- name: "Install GitLab and add helper to detect failed reconfigures"
block:
Expand Down
8 changes: 4 additions & 4 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
- name: Set OS distribution dependent variables
ansible.builtin.include_vars: "{{ ansible_facts['distribution'] }}.yml"

- name: Check whether gitlab-ctl binary is installed
- name: Check whether gitlab-rails binary is installed
ansible.builtin.stat:
path: "/usr/bin/gitlab-ctl"
register: gitlab_ctl
path: "/usr/bin/gitlab-rails"
register: gitlab_rails_binary

- name: Determine if this is an initial dry-run
ansible.builtin.set_fact:
is_initial_dryrun: "{{ ansible_check_mode and not gitlab_ctl.stat.exists }}"
is_initial_dryrun: "{{ ansible_check_mode and not gitlab_rails_binary.stat.exists }}"

- name: Check if a previous reconfigure had failed
ansible.builtin.stat:
Expand Down