Database loadbalancing wrongly applied to webservice and sidekiq when using pgbouncer
Summary
When configuring database load balancing in the GitLab Helm Chart (https://docs.gitlab.com/ee/administration/postgresql/database_load_balancing.html#enabling-load-balancing), and using a pgbouncer approach as in !2973, only the toolbox
gets the appropriate configuration under /var/opt/gitlab/templates/database.yml.erb
. This configuration should be present under webservice
and sidekiq
components too.
Steps to reproduce
Given the following values.yaml
file:
global:
psql:
host: my-primary-host.cern.ch
password:
secret: gitlab-dbod-credentials
key: gitlab-passwd
database: gitlab
port: 5432
username: gitlab
###! Database loadbalancing for read-only replica
###! https://docs.gitlab.com/ee/administration/postgresql/database_load_balancing.html
load_balancing:
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
hosts:
- my-secondary-host.cern.ch
At the time of updating the helm release the new configuration is only applied to the gitlab-toolbox
component.
Current behavior
# Puma
oc rsh deploy/gitlab-webservice-default cat /var/opt/gitlab/templates/database.yml.erb
production:
main:
adapter: postgresql
encoding: unicode
database: gitlab
username: gitlab
password: <%= File.read('/etc/gitlab/postgres/psql-password-main').strip.to_json %>
host: "gitlab-pgbouncer"
port: 5432
connect_timeout:
keepalives:
keepalives_idle:
keepalives_interval:
keepalives_count:
tcp_user_timeout:
application_name:
prepared_statements: false
database_tasks: true
# missing here
# Sidekiq
oc rsh deploy/gitlab-sidekiq-all-v2 cat /var/opt/gitlab/templates/database.yml.erb
production:
main:
adapter: postgresql
encoding: unicode
database: gitlab
username: gitlab
password: <%= File.read('/etc/gitlab/postgres/psql-password-main').strip.to_json %>
host: "gitlab-pgbouncer"
port: 5432
connect_timeout:
keepalives:
keepalives_idle:
keepalives_interval:
keepalives_count:
tcp_user_timeout:
application_name:
prepared_statements: false
database_tasks: true
# missing here
# Toolbox. It is present here
oc rsh deploy/gitlab-toolbox cat /var/opt/gitlab/templates/database.yml.erb
production:
main:
adapter: postgresql
encoding: unicode
database: gitlab
username: gitlab
password: <%= File.read('/etc/gitlab/postgres/psql-password-main').strip.to_json %>
host: "my-primary-host.cern.ch"
port: 5432
connect_timeout:
keepalives:
keepalives_idle:
keepalives_interval:
keepalives_count:
tcp_user_timeout:
application_name:
prepared_statements: false
database_tasks: true
load_balancing:
hosts:
- my-secondary-host.cern.ch
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
Expected behavior
# Puma
oc rsh deploy/gitlab-webservice-default cat /var/opt/gitlab/templates/database.yml.erb
production:
main:
adapter: postgresql
encoding: unicode
database: gitlab
username: gitlab
password: <%= File.read('/etc/gitlab/postgres/psql-password-main').strip.to_json %>
host: "gitlab-pgbouncer"
port: 5432
connect_timeout:
keepalives:
keepalives_idle:
keepalives_interval:
keepalives_count:
tcp_user_timeout:
application_name:
prepared_statements: false
database_tasks: true
load_balancing:
hosts:
- my-secondary-host.cern.ch
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
# Sidekiq
oc rsh deploy/gitlab-sidekiq-all-v2 cat /var/opt/gitlab/templates/database.yml.erb
production:
main:
adapter: postgresql
encoding: unicode
database: gitlab
username: gitlab
password: <%= File.read('/etc/gitlab/postgres/psql-password-main').strip.to_json %>
host: "gitlab-pgbouncer"
port: 5432
connect_timeout:
keepalives:
keepalives_idle:
keepalives_interval:
keepalives_count:
tcp_user_timeout:
application_name:
prepared_statements: false
database_tasks: true
load_balancing:
hosts:
- my-secondary-host.cern.ch
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
# Toolbox. It is present here
oc rsh deploy/gitlab-toolbox cat /var/opt/gitlab/templates/database.yml.erb
production:
main:
adapter: postgresql
encoding: unicode
database: gitlab
username: gitlab
password: <%= File.read('/etc/gitlab/postgres/psql-password-main').strip.to_json %>
host: "my-primary-host.cern.ch"
port: 5432
connect_timeout:
keepalives:
keepalives_idle:
keepalives_interval:
keepalives_count:
tcp_user_timeout:
application_name:
prepared_statements: false
database_tasks: true
load_balancing:
hosts:
- my-secondary-host.cern.ch
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
# And any other component that needs it...
So in the case of using pgbouncer
, a new example should be provided to clarify how to configure both webservice
and sidekiq
(as https://gitlab.com/gitlab-org/charts/gitlab/-/blob/master/examples/database/values-loadbalancing.yaml).
New example should contain:
global:
psql:
host: my-primary-host.cern.ch
password:
secret: gitlab-dbod-credentials
key: gitlab-passwd
database: gitlab
port: 5432
username: gitlab
###! Database loadbalancing for read-only replica
###! https://docs.gitlab.com/ee/administration/postgresql/database_load_balancing.html
load_balancing:
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
hosts:
- my-secondary-host.cern.ch
...
gitlab:
webservice:
psql:
...
load_balancing:
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
hosts:
- my-secondary-host.cern.ch
sidekiq:
psql:
...
load_balancing:
max_replication_difference: 8388608
max_replication_lag_time: 60
replica_check_interval: 60
hosts:
- my-secondary-host.cern.ch