Пост

Обновление GitLab selfhosted до 17.0

В данной статье мы решим проблему обновления на PostgreSQL 14 для GitLab

Предисловие

На днях решил обновить GitLab до 17.0 версии. В ходе обновления возникла необходимость обновить версию PostgreSQL до 14 версии, так, как новая версия GitLab отказывалась работать с версиями ниже. До этого момента решение обновления PostgreSQL откладывал до последнего. Да и автоматическое обновление отключил с помощью

1
/etc/gitlab/disable-postgresql-upgrade 

Установка и обновление

При обновлении Gitlab до 17.0 требовалось обновить PostgreSQL

1
2
3
4
5
6
7
Preparing to unpack .../gitlab-ce_17.0.1-ce.0_amd64.deb ...
gitlab preinstall: 
gitlab preinstall: Your version of PostgreSQL is no longer supported. Please upgrade your PostgreSQL version to 14.
gitlab preinstall: Check https://docs.gitlab.com/omnibus/settings/database.html#upgrade-packaged-postgresql-server for details.
gitlab preinstall: 
gitlab preinstall: Upgrade failed. Retry the upgrade after upgrading your PostgreSQL version.
dpkg: error processing archive /var/cache/apt/archives/gitlab-ce_17.0.1-ce.0_amd64.deb (--unpack):

Так, как автоматическое обновление было отключено, обновить требовалось командой

1
sudo gitlab-ctl pg-upgrade -V 14   

Но в после обновления данные не перенеслись в новую БД и соответственно при чтении логов gitlab-ctl tail получали ошибку

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
==> /var/log/gitlab/gitlab-rails/application_json.log <==
{"severity":"WARN","time":"2024-05-28T11:56:05.251Z","message":"Cached record for ApplicationSetting couldn't be loaded, falling back to uncached record: PG::UndefinedTable: ERROR:  relation \"application_settings\" does not exist\nLINE 9:  WHERE a.attrelid = '\"application_settings\"'::regclass\n                            ^\n"}

==> /var/log/gitlab/postgresql/current <==
2024-05-28_11:56:05.25241 ERROR:  relation "application_settings" does not exist at character 491
2024-05-28_11:56:05.25242 STATEMENT:  SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2024-05-28_11:56:05.25242              pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
2024-05-28_11:56:05.25242              c.collname, col_description(a.attrelid, a.attnum) AS comment,
2024-05-28_11:56:05.25242              attgenerated as attgenerated
2024-05-28_11:56:05.25243         FROM pg_attribute a
2024-05-28_11:56:05.25243         LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2024-05-28_11:56:05.25243         LEFT JOIN pg_type t ON a.atttypid = t.oid
2024-05-28_11:56:05.25243         LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
2024-05-28_11:56:05.25243        WHERE a.attrelid = '"application_settings"'::regclass
2024-05-28_11:56:05.25244          AND a.attnum > 0 AND NOT a.attisdropped
2024-05-28_11:56:05.25244        ORDER BY a.attnum
2024-05-28_11:56:05.25244 

==> /var/log/gitlab/sidekiq/current <==
PG::UndefinedTable: ERROR:  relation "application_settings" does not exist
LINE 9:  WHERE a.attrelid = '"application_settings"'::regclass
                            ^

В моём случае ошибка возникала, из-за немного кривых прав на дирректорию /var/opt/gitlab/postgresql и использования zsh вместо обычного bash

Для решения проблемы обновления

  1. Откатываем обновление PostgreSQL с помощью команды sudo gitlab-ctl revert-pg-upgrade
  2. Проверяем доступность GitLab
  3. Выдаём корректные права sudo chown -R gitlab-psql:gitlab-psql /var/opt/gitlab/postgresql
  4. Меняем SHELL на bash
  5. Выполняем апгрейд PostgreSQL командой sudo gitlab-ctl pg-upgrade -V 14
Авторский пост защищен лицензией CC BY 4.0 .