一次 gitlab 升级失败的处理过程记录

这次升级是从 15.8.3 升级至 15.9.1 ,通过下面的 rpm 安装命令进行升级

rpm -Uvh gitlab-ce-15.9.1-ce.0.el7.x86_64.rpm

升级过程中卡在 gitlab::database_migrations 很长时间

Recipe: gitlab::database_migrations
  * ruby_block[check remote PG version] action nothing (skipped due to action :nothing)
  * rails_migration[gitlab-rails] action run
    * bash_hide_env[migrate gitlab-rails database] action run

在卡住的过程中,centos 系统中一直有个 bundle 进程在运行。

等了一段时间后看不到进展,于是 control + c 强制结束安装并通过下面的命令尝试降级回 15.8.3

rpm -Uvh gitlab-ce-15.8.3-ce.0.el7.x86_64.rpm --oldpackage

降级因为下面的错误而失败

Malformed configuration JSON file found at /opt/gitlab/embedded/nodes/gitlab.json.
This usually happens when your last run of gitlab-ctl reconfigure didn't complete successfully.
This file is used to check if any of the unsupported configurations are enabled,
and hence require a working reconfigure before upgrading.
Please run sudo gitlab-ctl reconfigure to fix it and try again.

删除 gitlab.json 文件后降级成功

/opt/gitlab/embedded/nodes/gitlab.json
rpm -Uvh gitlab-ce-15.8.3-ce.0.el7.x86_64.rpm --oldpackage

参考 rails_migration[gitlab-rails] action run fails 中的评论,改用手动档模式升级:

1)禁用自动 reconfigure:添加 skip-auto-reconfigure 文件

touch /etc/gitlab/skip-auto-reconfigure

2)禁用自动迁移:/etc/gitlab/gitlab.rb 在添加下面的配置

gitlab_rails['auto_migrate'] = false

3)执行升级命令

rpm -Uvh gitlab-ce-15.9.1-ce.0.el7.x86_64.rpm

注:问题是升级过程中的数据库迁移引起的,禁用自动迁移后,升级能完成

4)执行 gitlab:background_migrations

gitlab-rake gitlab:background_migrations:finalize[ProjectNamespaces::BackfillProjectNamespaces,projects,id,'[null\,"up"]']

5)迁移数据库

gitlab-rake db:migrate

在执行 ClearDuplicateJobsCookies 时卡住,也是 centos 系统中一直有个 bundle 进程在运行,这次耐心地等下去

main: == 20230117114739 ClearDuplicateJobsCookies: migrating ========================

终于等到迁移完成,迁移数据竟然需要25分钟,难怪之前没有耐心等下去

main: == 20230117114739 ClearDuplicateJobsCookies: migrated (1519.2884s) ============

6)重新配置 gitlab

gitlab-ctl reconfigure

7)重启 gitlab

gitlab-ctl restart

(升级成功完成)

posted @ 2023-02-25 16:37  dudu  阅读(938)  评论(0编辑  收藏  举报