Project CI/CD Analytics charts are empty if rails timezone is non-UTC
Summary
When the local timezone and locale information of a GitLab application is non-UTC, and the database connections it makes always return UTC values, the CI/CD Analytics charts under a project do not load anymore (all values shown are 0).
This is happening since 13.6 due to the changes introduced via !47069 (merged)
This is a bit severe since it affects all projects, and changing default timezone of the rails configuration to UTC as a workaround may not be an acceptable change due to its probable use in scheduling, etc. within GitLab.
Steps to reproduce
- Setup GitLab on a machine with a non-UTC timezone, such that
Date
objects ingitlab-rails
produce non-UTC value formatting by default. - Run some pipelines.
- Try to load project analytics CI/CD charts. They should appear with a flat 0-line.
- Go back to config and reset rails timezone to UTC, reconfigure.
- Load charts. They appear normal again.
Example Project
(Only affects self-managed installations with customized time_zone
rails configs, as GitLab.com likely runs on a unified timezone (all-UTC)).
What is the current bug behavior?
Charts do not load for very specific self-managed deployments that use non-UTC default rails timezone.
What is the expected correct behavior?
Charts should load regardless of rails timezone settings (behavior prior to !47069 (merged)).
Relevant logs and/or screenshots
Some additional information is available on a premium customer ticket (internal link: https://gitlab.zendesk.com/agent/tickets/184955)
Another starter customer hitting the same issue: https://gitlab.zendesk.com/agent/tickets/184819 (internal link)
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.2p137 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.1 Redis Version: 5.0.9 Git Version: 2.29.0 Sidekiq Version:5.2.9 Go Version: unknown GitLab information Version: 13.6.3-ee Revision: 8578025c5e8 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 11.9 URL: http://localhost HTTP Clone URL: http://localhost/some-group/some-project.git SSH Clone URL: git@localhost:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.13.0 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
Checking GitLab subtasks ...
Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.13.0 ? ... OK (13.13.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... skipped (no tmp uploads folder yet) Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 2/1 ... yes 1/2 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.29.0 ? ... yes (2.29.0) Git user has default SSH configuration? ... yes Active users: ... 1 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
The specific issue is due to the removal of key-formatting: !47069 (diffs)
Due to the returned DB values for timestamp
type not being formatted as plain strings anymore, they carry a time component (always 00:00:00
, but in UTC) that is equated when a lookup is performed here with local Date objects (which can carry a non-UTC timestamp): https://gitlab.com/gitlab-org/gitlab/-/blob/e4f7882e402a6abd123e6bcd586c89fbbb61c410/lib/gitlab/ci/charts.rb#L35-36
Since the lookup fails, the value for the date is set as 0
for the charts.