JH GitLab 16.10.0 数据库初始化报错
Summary
数据库初始化报错
Recipe: gitlab::database_migrations
* ruby_block[check remote PG version] action nothing (skipped due to action :nothing)
* rails_migration[gitlab-rails] action run[2024-03-22T15:58:51+00:00] WARN: gitlab-rails does not have a log_group or default logdir mode defined. Setting to 0700.
* bash_hide_env[migrate gitlab-rails database] action run
[execute] rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "features" does not exist
LINE 9: WHERE a.attrelid = '"features"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in `columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in `columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:109:in `persisted_names'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:116:in `persisted_name?'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:311:in `block in current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:329:in `with_feature'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:310:in `current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:130:in `enabled?'
/opt/gitlab/embedded/service/gitlab-rails/jh/config/initializers/disable_duo_pro.rb:4:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `<main>'
Caused by:
PG::UndefinedTable: ERROR: relation "features" does not exist
LINE 9: WHERE a.attrelid = '"features"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in `columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in `columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:109:in `persisted_names'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:116:in `persisted_name?'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:311:in `block in current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:329:in `with_feature'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:310:in `current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:130:in `enabled?'
/opt/gitlab/embedded/service/gitlab-rails/jh/config/initializers/disable_duo_pro.rb:4:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `<main>'
Tasks: TOP => gitlab:db:configure => environment
(See full trace by running task with --trace)
================================================================================
Error executing action `run` on resource 'bash_hide_env[migrate gitlab-rails database]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of "bash" ----
STDOUT: rake aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "features" does not exist
LINE 9: WHERE a.attrelid = '"features"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in `columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in `columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:109:in `persisted_names'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:116:in `persisted_name?'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:311:in `block in current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:329:in `with_feature'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:310:in `current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:130:in `enabled?'
/opt/gitlab/embedded/service/gitlab-rails/jh/config/initializers/disable_duo_pro.rb:4:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `<main>'
Caused by:
PG::UndefinedTable: ERROR: relation "features" does not exist
LINE 9: WHERE a.attrelid = '"features"'::regclass
^
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:27:in `columns'
/opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/database/schema_cache_with_renamed_table_legacy.rb:31:in `columns_hash'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:109:in `persisted_names'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:116:in `persisted_name?'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:311:in `block in current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:329:in `with_feature'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:310:in `current_feature_value'
/opt/gitlab/embedded/service/gitlab-rails/lib/feature.rb:130:in `enabled?'
/opt/gitlab/embedded/service/gitlab-rails/jh/config/initializers/disable_duo_pro.rb:4:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:7:in `<top (required)>'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
/opt/gitlab/embedded/bin/bundle:25:in `load'
/opt/gitlab/embedded/bin/bundle:25:in `<main>'
Tasks: TOP => gitlab:db:configure => environment
(See full trace by running task with --trace)
STDERR:
---- End output of "bash" ----
Ran "bash" returned 1
Cookbook Trace: (most recent call first)
----------------------------------------
/opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/rails_migration.rb:20:in `block in class_from_file'
Resource Declaration:
---------------------
# In /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/rails_migration.rb
20: bash_hide_env "migrate #{new_resource.name} database" do
21: code <<-EOH
22: set -e
23: log_file="#{logging_settings[:log_directory]}/#{new_resource.logfile_prefix}-$(date +%Y-%m-%d-%H-%M-%S).log"
24: umask 077
25: /opt/gitlab/bin/gitlab-rake #{new_resource.rake_task} 2>& 1 | tee ${log_file}
26: STATUS=${PIPESTATUS[0]}
27: chown #{account_helper.gitlab_user}:#{account_helper.gitlab_group} ${log_file}
28: echo $STATUS > #{new_resource.helper.db_migrate_status_file}
29: exit $STATUS
30: EOH
31:
32: environment new_resource.environment if new_resource.property_is_set?(:environment)
33: new_resource.dependent_services.each do |svc|
34: notifies :restart, svc, :immediately
35: end
36:
37: not_if { new_resource.helper.migrated? }
38: sensitive false
39: end
40: end
Compiled Resource:
------------------
# Declared in /opt/gitlab/embedded/cookbooks/cache/cookbooks/gitlab/resources/rails_migration.rb:20:in `block in class_from_file'
bash_hide_env("migrate gitlab-rails database") do
action [:run]
default_guard_interpreter :default
interpreter "bash"
declared_type :bash_hide_env
cookbook_name "gitlab"
recipe_name "database_migrations"
code " set -e\n log_file=\"/var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-$(date +%Y-%m-%d-%H-%M-%S).log\"\n umask 077\n /opt/gitlab/bin/gitlab-rake gitlab:db:configure 2>& 1 | tee ${log_file}\n STATUS=${PIPESTATUS[0]}\n chown git:git ${log_file}\n echo $STATUS > /var/opt/gitlab/gitlab-rails/upgrade-status/db-migrate-c6697a9cd49e1cfa45cc31b1ecdb90ae-44947f3cc44\n exit $STATUS\n"
environment "*sensitive value suppressed*"
not_if { #code block }
end
System Info:
------------
chef_version=18.3.0
platform=ubuntu
platform_version=22.04
ruby=ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
program_name=/opt/gitlab/embedded/bin/cinc-client
executable=/opt/gitlab/embedded/bin/cinc-client
Steps to reproduce
- 用 all-in-one docker image 启动一个实例即可重现
docker run -it --name gitlab -p 8080:80 registry.gitlab.cn/omnibus/gitlab-jh:16.10.0-jh.0
Example Project
What is the current bug behavior?
What is the expected correct behavior?
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)
Possible fixes
由 Shiyuan Chen 编辑于