GitLab is storing `queued_at` in UTC regardless of the local TZ configuration
Problem to solve
GitLab is storing queued_at
in UTC regardless of the machine's TZ configuration
Further details
gitlabhq_production=> \d ci_builds;
Table "public.ci_builds"
Column | Type | Modifiers
--------------------------+-----------------------------+--------------------------------------------------------
created_at | timestamp without time zone |
...
gitlabhq_production=> select queued_at from ci_builds where queued_at is not null order by queued_at desc limit 5;
queued_at
----------------------------
2018-11-12 17:41:22.067669
2018-11-12 17:41:21.913956
2018-11-12 17:41:21.176312
2018-11-12 17:41:21.164961
2018-11-12 17:41:21.153861
Proposal
Several solutions seem reasonable without another setting:
1: work with the Rails developers to fix their datetime handling so that the PostgreSQL backend uses the "TIMESTAMP WITH TIME ZONE" field type, and values are inserted with UTC offset specified.
2: set the TZ environment variable to UTC in gitlab-ctl, so that all Gitlab processes run in UTC time, overriding the global system setting.
3: always write the "timezone = 'UTC'" value in postgresql.conf, so that at least the SQL server doesn't double the UTC offset.
What does success look like, and how can we measure that?
UTC values should be stored in a UTC type field
Links / references
ZD https://gitlab.zendesk.com/agent/tickets/108168 (internal)
Edited by Thiago Presa