gitlab-runner报错500修复

at 1年前  ca gitlab  pv 808  by touch  

gitlab备份恢复之后打开runner报错500

报错日志信息

Completed 200 OK in 1261ms (Views: 1.4ms | ActiveRecord: 0.0ms | Elasticsearch: 0.0ms | Allocations: 6128)
Started GET "/admin/runners" for 192.168.3.2 at 2022-09-05 07:25:08 +0000
Processing by Admin::RunnersController#index as HTML
  Rendered layout layouts/admin.html.haml (Duration: 59.5ms | Allocations: 46227)
Completed 500 Internal Server Error in 124ms (ActiveRecord: 16.1ms | Elasticsearch: 0.0ms | Allocations: 57051)
  
ActionView::Template::Error ():
    39: 
    40:     .col-sm-6
    41:       .bs-callout
    42:         = render partial: 'ci/runner/how_to_setup_runner',
    43:                   locals: { registration_token: Gitlab::CurrentSettings.runners_registration_token,
    44:                             type: 'shared',
    45:                             reset_token_url: reset_registration_token_admin_application_settings_path,
  
lib/gitlab/crypto_helper.rb:28:in `aes256_gcm_decrypt'
app/models/concerns/token_authenticatable_strategies/encryption_helper.rb:18:in `decrypt_token'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:45:in `get_token'
app/models/concerns/token_authenticatable_strategies/base.rb:38:in `ensure_token!'
app/models/concerns/token_authenticatable.rb:48:in `block in add_authentication_token_field'
app/models/application_setting_implementation.rb:365:in `runners_registration_token'
lib/gitlab/current_settings.rb:32:in `method_missing'
app/views/admin/runners/index.html.haml:42
app/controllers/application_controller.rb:128:in `render'
app/controllers/application_controller.rb:487:in `set_current_admin'

解决方案

root@txGitlabServer108:/var/log/gitlab/gitlab-rails# gitlab-rails dbconsole
psql (12.7)
Type "help" for help.

gitlabhq_production=> UPDATE projects SET runners_token = null, runners_token_encrypted = null;
UPDATE 247
gitlabhq_production=> UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
UPDATE 91
gitlabhq_production=> 
gitlabhq_production=> 
gitlabhq_production=> UPDATE application_settings SET runners_registration_token_encrypted = null;
UPDATE 1
gitlabhq_production=> UPDATE application_settings SET encrypted_ci_jwt_signing_key = null;
UPDATE 1
gitlabhq_production=> 
gitlabhq_production=> UPDATE ci_runners SET token = null, token_encrypted = null;
UPDATE 0
gitlabhq_production=>

Gitlab is version 14.x gitlab-rails dbconsole无法进去

用这个即可:

gitlab-psql -d gitlabhq_production

或者

sudo gitlab-rails dbconsole --database main //也能进但要点时间

解释

链接Gitlab官方文档

## Clear project tokens
UPDATE projects SET runners_token = null, runners_token_encrypted = null;
## Clear group tokens
UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;
## Clear instance tokens
UPDATE application_settings SET runners_registration_token_encrypted = null;
## Clear key used for JWT authentication
## This may break the $CI_JWT_TOKEN job variable:
## https://gitlab.com/gitlab-org/gitlab/-/issues/325965
UPDATE application_settings SET encrypted_ci_jwt_signing_key = null;
## Clear runner tokens
UPDATE ci_runners SET token = null, token_encrypted = null;


版权声明

本文仅代表作者观点,不代表码农殇立场。
本文系作者授权码农殇发表,未经许可,不得转载。

 

扫一扫在手机阅读、分享本文

已有0条评论