Skip to content

Timezone rake task outputs wrong timezone format

Summary

The timezones from gitlab-rake time:zones:all are pretty printed, indicating that the timezone in /etc/gitlab/gitlab.rb should be set with these timezones as-is.

Steps to reproduce

Following existing documentation: Changing your time zone

  1. Run gitlab-rake time:zones:all or gitlab-rake time:zones[<two-letter-country-code>] (to get fewer results)
  2. Copy timezone
  3. Edit gitlab_rails['time_zone'] in /etc/gitlab/gitlab.rb to the timezone, like so:
gitlab_rails['time_zone'] = 'Pacific Time'
  1. Run gitlab-ctl reconfigure

What is the current bug behavior?

After running the reconfigure, the setting will not be accepted

What is the expected correct behavior?

The timezone should be set correctly or the rake task should output the proper format.

Relevant logs and/or screenshots

There was an error running gitlab-ctl reconfigure:

execute[clear the gitlab-rails cache] (gitlab::gitlab-rails line 399) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/bin/gitlab-rake cache:clear ----
STDOUT:
STDERR: rake aborted!
ArgumentError: Invalid Timezone: Pacific Time
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/time_zone.rb:1:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:6:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'

Caused by:
TZInfo::InvalidTimezoneIdentifier: Invalid identifier
/opt/gitlab/embedded/service/gitlab-rails/config/initializers/time_zone.rb:1:in `<top (required)>'
/opt/gitlab/embedded/service/gitlab-rails/config/environment.rb:6:in `<top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => cache:clear => cache:clear:redis => environment
(See full trace by running task with --trace)
---- End output of /opt/gitlab/bin/gitlab-rake cache:clear ----
Ran /opt/gitlab/bin/gitlab-rake cache:clear returned 1

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

$ gitlab-rake gitlab:env:info

System information System: Ubuntu 16.04 Proxy: no Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.5 Go Version: unknown

GitLab information Version: 11.8.1-ee Revision: 39d0b2e Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql DB Version: 9.6.11 URL: http://gitlab.example.com HTTP Clone URL: http://gitlab.example.com/some-group/some-project.git SSH Clone URL: git@gitlab.example.com:some-group/some-project.git Elasticsearch: yes Geo: no Using LDAP: no Using Omniauth: yes Omniauth Providers: gitlab

GitLab Shell Version: 8.4.4 Repository storage paths:

  • default: /mnt/gitlab/default/repositories
  • storage1: /mnt/gitlab/storage1/repositories Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks Git: /opt/gitlab/embedded/bin/git

Results of GitLab application Check

Expand for output related to the GitLab application check

$ gitlab-rake gitlab:check SANITIZE=true Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 8.4.4 ? ... OK (8.4.4) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK

Access to /var/opt/gitlab/.ssh/authorized_keys: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK storage1 ... 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? ... yes 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: ... 1/9 ... yes 1/10 ... yes 1/11 ... yes 1/12 ... yes 1/13 ... yes 1/14 ... yes 1/15 ... yes 1/16 ... yes 1/17 ... yes 1/18 ... yes 1/19 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... yes Active users: ... 5 Elasticsearch version 5.6 - 6.x? ... yes (6.6.1)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Calling TZInfo::Timezone.all_identifiers in the rails console provides the proper format for timezones:

Screen_Shot_2019-03-07_at_2.05.11_PM

After adding gitlab_rails['time_zone'] = 'US/Pacific' to /etc/gitlab/gitlab.rb, the reconfigure is successful.

Edited by David Coy