在Gitlab EE中配置Azure PostgreSQL

在Gitlab EE中配置Azure PostgreSQL,gitlab,sidekiq,gitlab-omnibus,azure-postgresql,gitlab-ee,Gitlab,Sidekiq,Gitlab Omnibus,Azure Postgresql,Gitlab Ee,我正在搜索有关如何在基于Docker Swarm的Gitlab实例中配置Azure PostgreSQL DB的帮助 最初,我遵循中的文档。然而,我发现默认提供的用户是用户名形式的,而Azure要求它是用户名形式的username@hostname. 我尝试在gitlab.rb文件中传递用户名(gitlab\u rails['db\u username']='username@hostname“),但即使将@替换为URI编码的%40,它仍然失败 经过广泛的搜索,我找到了这个文档-,它建议使用DA

我正在搜索有关如何在基于Docker Swarm的Gitlab实例中配置Azure PostgreSQL DB的帮助

最初,我遵循中的文档。然而,我发现默认提供的用户是用户名形式的,而Azure要求它是用户名形式的username@hostname. 我尝试在gitlab.rb文件中传递用户名(
gitlab\u rails['db\u username']='username@hostname“
),但即使将@替换为URI编码的%40,它仍然失败

经过广泛的搜索,我找到了这个文档-,它建议使用
DATABASE\u URL
环境变量以
p的形式设置完整的连接字符串ostgresql://username:password@主机名:port/dbname
,我这样做了,它确实解决了Gitlab本身与Azure PostgreSQL通信的问题(在本例中,根据Azure要求,我将用户名替换为用户名%40hostname)

Allas,成功是短暂的,从那以后我发现Puma和Sidekiq都无法连接到数据库,总是抛出以下错误:

==> /var/log/gitlab/sidekiq/current <==
could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
(删除的数据库和用户名)

它几乎忽略了
DATABASE\u URL
env变量,并假定gitlab.rb中现在不存在的配置参数

所以,现在,我有点没有选择了,我想知道是否有人有过类似的问题,如果有,你如何克服这个问题

感谢您的帮助


提前感谢。

TL/DR:传递
username@hostname
gitlab_rails['db_username']中的字符串,用双引号直接插入。gitlab官方页面中用于连接Azure PostgreSQL的文档不正确

因此,在对Gitlab配置进行了一些搜索和深入研究之后,我发现这个问题非常具体,并且与docker secrets的使用有关

在我的gitlab.rb配置文件的数据库配置部分中,我使用了以下内容:

### GitLab database settings
###! Docs: https://docs.gitlab.com/omnibus/settings/database.html
###! **Only needed if you use an external database.**
gitlab_rails['db_adapter'] = "postgresql"
gitlab_rails['db_encoding'] = "unicode"
gitlab_rails['db_database'] = File.read('/run/secrets/postgresql_database')
gitlab_rails['db_username'] = File.read('/run/secrets/postgresql_user')
gitlab_rails['db_password'] = File.read('/run/secrets/postgresql_password')
gitlab_rails['db_host'] = File.read('/run/secrets/postgresql_host')
gitlab_rails['db_port'] = File.read('/run/secrets/postgresql_port')
gitlab_rails['db_sslmode'] = 'require'
现在,这个精确的配置以前用于测试目的,并且有效(但没有使用Azure PostgreSQL数据库)。我正在将正确的机密传递给docker,并且我已经确认这些机密事实上确实存在

(旁注:另外,我已经确定Gitlab使用Ruby ActiveRecord::Base库中的方法ActiveRecord::Base.build_connection来连接数据库)

然而,当使用username@hostname为用户配置并将其传递到postgresql\u用户机密中,ActiveRecord::Base.build\u连接方法突然假定
@hostname
是我要连接到的实际主机名。我已确认在do中正确生成了机密集装箱

现在,它变得更加奇怪,因为如果我通过username@hostname字符串直接指向gitlab.rb文件-gitlab_rails['db_username']参数-在双引号中,它突然开始连接而没有抱怨

因此,简而言之,如果将Azure PostgreSQL数据库用于停靠的Gitlab实例,并使用机密将配置传递到Gitlab.rb文件,不要传递
username@hostame
通过一个秘密,但将其直接放在gitlab.rb文件中

我不知道这是Ruby还是Gitlab的具体问题(我不是Ruby开发人员),但我确实尝试过将File.read输出转换为字符串,转换为符号,使用File.open('filepath',&:readline)和其他诡计,但没有任何效果。因此,如果有人愿意为此添加原因,请随意添加

此外,Azure提供的教程--不适用于Gitlab,因为它抱怨%40

希望这能帮助任何人

### GitLab database settings
###! Docs: https://docs.gitlab.com/omnibus/settings/database.html
###! **Only needed if you use an external database.**
gitlab_rails['db_adapter'] = "postgresql"
gitlab_rails['db_encoding'] = "unicode"
gitlab_rails['db_database'] = File.read('/run/secrets/postgresql_database')
gitlab_rails['db_username'] = File.read('/run/secrets/postgresql_user')
gitlab_rails['db_password'] = File.read('/run/secrets/postgresql_password')
gitlab_rails['db_host'] = File.read('/run/secrets/postgresql_host')
gitlab_rails['db_port'] = File.read('/run/secrets/postgresql_port')
gitlab_rails['db_sslmode'] = 'require'