You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

GitLab升级后Gitaly无法识别仓库目录问题求助

GitLab升级后Gitaly配置修改导致仓库无法访问问题

背景

按照GitLab官方流程升级至最新版本,原Git数据目录配置:

git_data_dirs({
  "default" => {
    "path" => "/data/gitlab/git-data"
   }
})

由于该配置后续会被移除,修改为Gitaly配置块形式:

gitaly['configuration'] = {
        pack_objects_cache: {
                # gitaly['pack_objects_cache_enabled']
                #enabled: ...,
                # gitaly['pack_objects_cache_dir']
                dir: '/data/gitlab/git-data/repositories/+gitaly/PackObjectsCache',
                # gitaly['pack_objects_cache_max_age']
                #max_age: ...,
        },
        storage: [
          {
               name: 'default',
               path: '/data/gitlab/git-data',
          },
      ],

}

仅新增storage节点,执行gitlab-ctl reconfigure后所有仓库无法访问,系统提示需创建新仓库,Gitaly日志报错:

{"component":"gitaly.UnaryServerInterceptor","correlation_id":"01K201FP807G32AW2YE3CEB","error":"repository not found","error_metadata":{"relative_path":"@hashed/1a/65/1a6562590ef19d1045d06288e9e6dcd71ccde5cee80f1d5a774eb.git","storage_name":"default"},"grpc.code":"NotFound","grpc.meta.auth_version":"v2","grpc.meta.client_name":"gitlab-web","grpc.meta.deadline_type":"regular","grpc.meta.method_operation":"accessor","grpc.meta.method_scope":"repository","grpc.meta.method_type":"unary","grpc.method":"FindDefaultBranchName","grpc.request.deadline":"2025-08-06T17:55:13.149","grpc.request.fullMethod":"/gitaly.RefService/FindDefaultBranchName","grpc.request.glProjectPath":"","grpc.request.glRepository":"project-50","grpc.request.payload_bytes":129,"grpc.request.repoPath":"@hashed/1a/65/1a6562590ef19d1045d06c4055742d38288e1ccde5cee80f1d5a774eb.git","grpc.request.repoStorage":"default","grpc.response.payload_bytes":0,"grpc.service":"gitaly.RefService","grpc.start_time":"2025-08-06T17:55:03.469","grpc.time_ms":0.174,"level":"info","msg":"finished unary call with code NotFound","pid":5947,"remote_ip":"172.31.190.70","span.kind":"server","system":"grpc","time":"2025-08-06T15:55:03.469Z","user_id":"2","username":""}

日志中relative_path对应的仓库文件实际存在,恢复原配置后一切正常。已确认git用户权限无问题,尝试重新升级、强制修改权限等操作均无效。

解决方案

  • 修正Gitaly存储路径配置:原git_data_dirs的路径指向/data/gitlab/git-data时,GitLab会自动在该路径下的repositories子目录查找仓库;而直接配置Gitaly的storage.path时,需要明确指定仓库所在的实际目录,即/data/gitlab/git-data/repositories。修改后的配置应为:
gitaly['configuration'] = {
        pack_objects_cache: {
                dir: '/data/gitlab/git-data/repositories/+gitaly/PackObjectsCache',
        },
        storage: [
          {
               name: 'default',
               path: '/data/gitlab/git-data/repositories',
          },
      ],
}
  • 执行配置更新与服务重启:
    1. 保存修改后的gitlab.rb配置文件
    2. 执行gitlab-ctl reconfigure应用配置
    3. 执行gitlab-ctl restart gitaly确保Gitaly服务加载新配置
  • 验证仓库访问:访问GitLab项目页面,确认仓库可正常加载,无"创建新仓库"提示

原因说明:原配置中git_data_dirs会自动处理repositories子目录的映射,而直接配置Gitaly存储路径时,必须指向仓库实际存放的目录层级,否则Gitaly会在错误的路径下查找仓库文件,导致"repository not found"错误。


内容的提问来源于stack exchange,提问作者Halindel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 13:52:35