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

Commit 91fb96f

Browse files
author
Norman Ziegner
authored
Merge pull request #131 from Normo/130-background-migration-check-on-gitlab-update-only
Check for background migration on GitLab update only
2 parents f5b0e57 + 30059fa commit 91fb96f

File tree

2 files changed

+33
-20
lines changed

2 files changed

+33
-20
lines changed

tasks/install.yml

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,39 @@
8585
update_cache: true
8686
check_mode: false
8787

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

93-
- name: Wait until all previous background migrations are processed.
94-
become: yes
95-
ansible.builtin.command:
96-
cmd: gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
97-
register: remaining
98-
until: remaining.stdout == "0"
99-
retries: 10
100-
delay: 10
101-
check_mode: no
102-
changed_when: remaining.rc != 0
93+
- name: Wait for background migrations on primary node
10394
when:
104-
- file.stat.exists
105-
- file.stat.executable
106-
- gitlab_is_primary is defined
10795
- gitlab_is_primary
96+
- gitlab_version_file.stat.exists
97+
- gitlab_rails_binary.stat.exists
98+
- gitlab_rails_binary.stat.executable
99+
block:
100+
- name: Get the currently installed GitLab version
101+
ansible.builtin.slurp:
102+
path: "/var/opt/gitlab/gitlab-rails/VERSION"
103+
register: gitlab_version_base64
104+
105+
- name: Set fact about installed GitLab version
106+
ansible.builtin.set_fact:
107+
gitlab_installed_version: "{{ gitlab_version_base64['content'] | b64decode }}"
108+
check_mode: no
109+
110+
- name: Wait until all previous background migrations are processed.
111+
become: yes
112+
ansible.builtin.command:
113+
cmd: gitlab-rails runner -e production 'puts Gitlab::BackgroundMigration.remaining'
114+
register: remaining
115+
until: remaining.stdout == "0"
116+
retries: 10
117+
delay: 10
118+
check_mode: no
119+
changed_when: false
120+
when: gitlab_version == '' or gitlab_installed_version is version(gitlab_version, operator='lt', strict=True)
108121

109122
- name: "Install GitLab and add helper to detect failed reconfigures"
110123
block:

tasks/main.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
- name: Set OS distribution dependent variables
99
ansible.builtin.include_vars: "{{ ansible_facts['distribution'] }}.yml"
1010

11-
- name: Check whether gitlab-ctl binary is installed
11+
- name: Check whether gitlab-rails binary is installed
1212
ansible.builtin.stat:
13-
path: "/usr/bin/gitlab-ctl"
14-
register: gitlab_ctl
13+
path: "/usr/bin/gitlab-rails"
14+
register: gitlab_rails_binary
1515

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

2020
- name: Check if a previous reconfigure had failed
2121
ansible.builtin.stat:

0 commit comments

Comments
 (0)