Skip to content

Commit bb3d7e4

Browse files
authored
Merge pull request #455 from Normo/registry-database-migrations
Make sure to run registry metadata database migrations
2 parents 2064f89 + 7e8d496 commit bb3d7e4

File tree

6 files changed

+62
-13
lines changed

6 files changed

+62
-13
lines changed

molecule/gitlab/molecule.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ provisioner:
4040
- key: "env"
4141
type: "plain"
4242
value: "{ 'OWN_PRIVATE_API_URL' => 'grpc://127.0.0.1:8155' }"
43+
- registry:
44+
- key: "database"
45+
type: "plain"
46+
value: |-
47+
{
48+
'enabled' => false,
49+
'host' => '{{ gitlab_postgresql_db_host }}',
50+
'port' => {{ gitlab_postgresql_db_port }},
51+
'user' => 'gitlab',
52+
'password' => '{{ gitlab_postgresql_db_password }}',
53+
'dbname' => 'registry',
54+
'sslmode' => 'disable'
55+
}
4356
gitlab_feature_flags:
4457
# See https://docs.gitlab.com/ee/user/feature_flags.html
4558
- name: "vscode_web_ide"

roles/gitlab/handlers/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@
2020
listen: "GitLab has been installed or upgraded"
2121
when: "gitlab_is_primary"
2222

23+
- name: "Run registry metadata database migrations"
24+
become: true
25+
ansible.builtin.command: "gitlab-ctl registry-database migrate up --skip-post-deployment"
26+
changed_when: true
27+
when:
28+
- "__gitlab_registry_database_used"
29+
- "gitlab_is_primary"
30+
2331
- name: "Reconfigure Non Primary GitLab"
2432
become: true
2533
ansible.builtin.shell:

roles/gitlab/tasks/check.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# SPDX-FileCopyrightText: Helmholtz-Zentrum Dresden-Rossendorf (HZDR)
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
---
6+
7+
- name: "Check whether gitlab-rails binary is installed"
8+
ansible.builtin.stat:
9+
path: "/usr/bin/gitlab-rails"
10+
register: "gitlab_rails_binary"
11+
12+
- name: "Determine if this is an initial dry-run"
13+
ansible.builtin.set_fact:
14+
gitlab_is_initial_dryrun: "{{ ansible_check_mode and not gitlab_rails_binary.stat.exists }}"
15+
16+
- name: "Check if a previous reconfigure had failed"
17+
ansible.builtin.stat:
18+
path: "/etc/gitlab/reconfigure_failed"
19+
register: "gitlab_reconfigure_failed"
20+
21+
- name: "Check if registry configuration exists"
22+
ansible.builtin.set_fact:
23+
__gitlab_registry_config: "{{ item.registry }}"
24+
when: "item.registry is defined"
25+
loop: "{{ gitlab_additional_configurations }}"
26+
27+
- name: "Check if database key is defined in registry"
28+
ansible.builtin.set_fact:
29+
__gitlab_registry_database_used: "{{ __gitlab_registry_config | default([]) | selectattr('key', '==', 'database') | list | length > 0 }}"

roles/gitlab/tasks/configure.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
no_log: "{{ gitlab_hide_sensitive_changes }}"
1818
notify:
1919
- "Reconfigure Primary GitLab"
20+
- "Run registry metadata database migrations"
2021
- "Reconfigure Non Primary GitLab"
2122

2223
- name: "Ensure gitaly['configuration'] is not present in gitlab_additional_configurations"
@@ -55,6 +56,7 @@
5556
no_log: "{{ gitlab_hide_sensitive_changes }}"
5657
notify:
5758
- "Reconfigure Primary GitLab"
59+
- "Run registry metadata database migrations"
5860
- "Reconfigure Non Primary GitLab"
5961

6062
- name: "Create file to prevent Gitlab to restart before migrations"

roles/gitlab/tasks/main.yml

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

11-
- name: "Check whether gitlab-rails binary is installed"
12-
ansible.builtin.stat:
13-
path: "/usr/bin/gitlab-rails"
14-
register: "gitlab_rails_binary"
15-
16-
- name: "Determine if this is an initial dry-run"
17-
ansible.builtin.set_fact:
18-
gitlab_is_initial_dryrun: "{{ ansible_check_mode and not gitlab_rails_binary.stat.exists }}"
19-
20-
- name: "Check if a previous reconfigure had failed"
21-
ansible.builtin.stat:
22-
path: "/etc/gitlab/reconfigure_failed"
23-
register: "gitlab_reconfigure_failed"
11+
- name: "Perform prerequisite checks"
12+
ansible.builtin.import_tasks: "check.yml"
2413

2514
- name: "Reconfigure GitLab"
2615
ansible.builtin.import_tasks: "reconfigure.yml"

roles/gitlab/tasks/reconfigure.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
when:
2222
- "not gitlab_is_primary"
2323

24+
- name: "Run registry metadata database migrations"
25+
become: true
26+
ansible.builtin.command: "gitlab-ctl registry-database migrate up --skip-post-deployment"
27+
changed_when: true
28+
when:
29+
- "__gitlab_registry_database_used"
30+
- "gitlab_is_primary"
31+
2432
- name: "Remove file that indicates a failed reconfigure"
2533
ansible.builtin.file:
2634
path: "/etc/gitlab/reconfigure_failed"

0 commit comments

Comments
 (0)