暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

gitlab迁移之后删除项目500错误处理

雪狼sunny 2024-01-24
1377

背景:根据公司的规定,gitlab项目必须在特定的组中,不允许建立在个人用户下面,要清理个人用户下的所有项目,进行迁移或者删除处理,在删除个人用户的项目时候,发现项目都是无法删除,报错500;

排查原因:直接谷歌搜索


发现这个问题不是个例,很多类似的问题,于是看几篇文章进行对比,找一篇和自己环境吻合度很高的进行操作;

解决问题:

gitlab在迁移以后,原有服务器中的postgsql的project表中的token没有同步过来;

进入gitlab的pg数据库

[root@ip-10-99-3-200 ~]# gitlab-psql 
psql (12.7)
Type "help" for help.

gitlabhq_production=# \d
                                        List of relations
 Schema |                           Name                            |       Type        | Owner  
--------+-----------------------------------------------------------+-------------------+--------
 public | abuse_reports                                             | table             | gitlab
 public | abuse_reports_id_seq                                      | sequence          | gitlab
 public | agent_group_authorizations                                | table             | gitlab
 public | agent_group_authorizations_id_seq                         | sequence          | gitlab
 public | agent_project_authorizations                              | table             | gitlab
 public | agent_project_authorizations_id_seq                       | sequence          | gitlab
 public | alert_management_alert_assignees                          | table             | gitlab
 public | alert_management_alert_assignees_id_seq                   | sequence          | gitlab
 public | alert_management_alert_user_mentions                      | table             | gitlab
 public | alert_management_alert_user_mentions_id_seq               | sequence          | gitlab
 public | alert_management_alerts                                   | table             | gitlab
 public | alert_management_alerts_id_seq                            | sequence          | gitlab
 public | alert_management_http_integrations                        | table             | gitlab
 public | alert_management_http_integrations_id_seq                 | sequence          | gitlab
 public | allowed_email_domains                                     | table             | gitlab
 public | allowed_email_domains_id_seq                              | sequence          | gitlab


gitlabhq_production=# select * from projects;
 id  |                name                 |               path               |                                                                             description                                                                             |         cr
eated_at         |         updated_at         | creator_id | namespace_id |      last_activity_at      | import_url | visibility_level | archived | avatar | merge_requests_template | star_count | merge_requests_rebase_enabled |  import_type   | import_sour
ce | approvals_before_merge | reset_approvals_on_push | merge_requests_ff_only_enabled | issues_template | mirror | mirror_last_update_at | mirror_last_successful_update_at | mirror_user_id | shared_runners_enabled | runners_token | build_coverage_regex | 
build_allow_git_fetch | build_timeout | mirror_trigger_builds | pending_delete | public_builds | last_repository_check_failed |  last_repository_check_at  | only_allow_merge_if_pipeline_succeeds | has_external_issue_tracker | repository_storage | repositor
y_read_only | request_access_enabled | has_external_wiki | ci_config_path | lfs_enabled |                                                                                                      description_html                                                 
                                                      | only_allow_merge_if_all_discussions_are_resolved | repository_size_limit | printing_merge_request_link_enabled | auto_cancel_pending_pipelines | service_desk_enabled | cached_markdown_version | delete
_error | last_repository_updated_at | disable_overriding_approvers_per_merge_request | storage_version | resolve_outdated_diff_discussions | remote_mirror_available_overridden | only_mirror_protected_branches | pull_mirror_available_overridden | jobs_cache
_index | external_authorization_classification_label | mirror_overwrites_diverged_branches | pages_https_only | external_webhook_token | packages_enabled | merge_requests_author_approval | pool_repository_id | runners_token_encrypted | bfg_object_map | det
ected_repository_languages | merge_requests_disable_committers_approval | require_password_to_approve | emails_disabled | max_pages_size | max_artifacts_size | pull_mirror_branch_prefix | remove_source_branch_after_merge | marked_for_deletion_at | marked_f
or_deletion_by_user_id | autoclose_referenced_issues | suggestion_commit_message | project_namespace_id 
-----+-------------------------------------+----------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------
-----------------+----------------------------+------------+--------------+----------------------------+------------+------------------+----------+--------+-------------------------+------------+-------------------------------+----------------+------------
---+------------------------+-------------------------+--------------------------------+-----------------+--------+-----------------------+----------------------------------+----------------+------------------------+---------------+----------------------+-
----------------------+---------------+-----------------------+----------------+---------------+------------------------------+----------------------------+---------------------------------------+----------------------------+--------------------+----------
------------+------------------------+-------------------+----------------+-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------+--------------------------------------------------+-----------------------+-------------------------------------+-------------------------------+----------------------+-------------------------+-------
-------+----------------------------+------------------------------------------------+-----------------+-----------------------------------+------------------------------------+--------------------------------+----------------------------------+-----------
-------+---------------------------------------------+-------------------------------------+------------------+------------------------+------------------+--------------------------------+--------------------+-------------------------+----------------+----
---------------------------+--------------------------------------------+-----------------------------+-----------------+----------------+--------------------+---------------------------+----------------------------------+------------------------+---------
-----------------------+-----------------------------+---------------------------+----------------------

然后执行数据库的update命令:

gitlabhq_production=>  UPDATE projects SET runners_token = null, runners_token_encrypted = null;

gitlabhq_production=>  UPDATE namespaces SET runners_token = null, runners_token_encrypted = null;

gitlabhq_production=>  UPDATE application_settings SET runners_registration_token_encrypted = null;

经过一系列的操作,gitlab恢复正常可以正常删除项目了,也不抱500错误了;

我这么操作是不是觉得很大胆,前提是我的gitlab做了备份,即使操作错了也可以恢复,技术道路任重道远,每天学习一点点时间长了你也可以成就大神,继续吧。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论