Fix time zone config not respected in multi-threaded servers
Previously in multi-threaded app servers, such as Puma, the Rails time zone configuration setting was not being respected. Rails expects the time zone to be set in `application.rb`, and the default value is set in the `active_support.initialize_time_zone` Railtie. However, since we load this setting from a config file, the time zone for GitLab is set inside an initializer. Setting `Time.zone` in the initializer worked fine with Unicorn, but it stopped working with Puma. All responses would return timestamps in UTC, irrespective of the system or Rails time zone. This happened because `Time.zone` calls `Thread.current`. Since the time zone wasn't set for the thread, Puma would default to `Time.zone_default`, which was UTC. We now set the default and the Rails configuration settings to be consistent. Closes https://gitlab.com/gitlab-org/gitlab/-/issues/233259
Showing
Please register or sign in to comment