Skip to content

[gitlab-exporter] Exporter doesn't fetch metrics from Postgres due to explicit quotation of `gitlab.global.psql.host` value

Summary

We're using standalone Postgres installation.
After specifying gitlab.global.psql.host everything is work as expected expect of exporter - it doesn't fetch metrics from postgres.
Chart's default ConfigMap is used.
Seems that problem is introduced here - https://gitlab.com/gitlab-org/charts/gitlab/blob/master/templates/_helpers.tpl#L127

Steps to reproduce

Provide gitlab.global.psql.host from standalone postgres and try to retrieve /database metrics from gitlab-exporter

Configuration used

values.yaml:

gitlab:
  global:
    psql:
      password:
        secret: gitlab-postgres-secret
        key: password
      host: "postgres-service.postgres.svc.cluster.local"
      port: 5432
      username: "gitlab"
      database: "gitlab"

Rendered ConfigMap for gitlab-gitlab-exporter (non-working)

probes:
      db_common: &db_common
        methods:
          - probe_db
        opts:
          connection_string: dbname=gitlab user=gitlab host="postgres-service.postgres.svc.cluster.local" port=5432 password='<%= File.read("/etc/gitlab/postgres/psql-password").strip.gsub(/[\'\\]/) { |esc| '\\' + esc } %>'

But if we tried to manually replace this section in ConfigMap with:

probes:
      db_common: &db_common
        methods:
          - probe_db
        opts:
          connection_string: dbname=gitlab user=gitlab host=postgres-service.postgres.svc.cluster.local port=5432 password='<%= File.read("/etc/gitlab/postgres/psql-password").strip.gsub(/[\'\\]/) { |esc| '\\' + esc } %>'

Everything is work as expected

Current behavior

  • host value in exporter's configmap became quoted and metrics not working
  • no exception threw

Expected behavior

  • host value in exporter's configmap became unquoted and exporter is able to retrieve data from postgres
  • exception being threw if cannot connect to postgres

Versions

  • Chart: 2.3.7
  • Platform:
    • Self-hosted: Kubernetes
  • Kubernetes: (kubectl version)
    • Client: v1.11.2
    • Server: v1.11.2
  • Helm: (helm version)
    • Client: v2.14.3
    • Server: v2.14.3
Edited by Valentin Zayash