Skip to content

First thread doesn't get correct timezone #1467

Description

@mattpgh

Describe the bug
The first thread that Thruk launches seems to always use the OS timezone, as opposed to the server_timezone value in thruk_local.conf

Thruk Version
Thruk 3.22 (not using OMD)
Running on Ubuntu 22.04 via uwsgi

To Reproduce
Steps to reproduce the behavior:

  1. Have the OS ( /etc/timezone ) configured to a different timezone than Thruk ( /etc/thruk/thruk_local.conf server_timezone ).
cat /etc/timezone
Etc/UTC
grep server_timezone /etc/thruk/thruk_local.conf
server_timezone=America/New_York
  1. Configure UWSGI to launch thruk with 1 process and 2 (or more) threads. This is my uwsgi configuration for thruk in /etc/uwsgi/apps-enabled/thruk.ini:
plugin = psgi
socket = 127.0.0.1:4040
master = true
processes = 1
threads = 2
env = THRUK_CONFIG=/etc/thruk
env = PERL5LIB=$PERL5LIB:/usr/share/thruk/lib/:/usr/lib/thruk/perl5:/usr/lib/x86_64-linux-gnu/perl-base
psgi = /usr/share/thruk/script/thruk.psgi
buffer-size=32768
  1. Restart UWSGI to make this configuration live
  2. Load the User Profile page in a browser ( /thruk/cgi-bin/user.cgi ). The bottom right tells you the Server timezone. Take note of the timezone value
Image 5. Reload the User Profile page a few times. Depending on the thread that processes your request, you will see either the OS or Thruk configured timezone Image

Expected behavior
All Thruk threads and every request for the User Profile get the server_timezone value from thruk_local.conf,

Workaround
I can force Thruk to have the correct server timezone by adding the following line to the Thruk UWSGI configuration (/etc/uwsgi/apps-enabled/thruk.ini)
env = TZ=America/New_York

Additional context
If you also set thruk_verbose=2 in thruk_local.conf you can see the problem in the Thruk logs. This example is with 1 process 6 threads:

grep 'server timezone' /var/log/uwsgi/app/thruk.log
[14:15:53,318][DEBUG][.../Thruk/Utils/Timezone.pm:66] server timezone: Etc/UTC (from /etc/timezone)
[10:15:53,504][DEBUG][.../Thruk/Utils/Timezone.pm:59] server timezone: America/New_York (from ENV)
[10:15:53,673][DEBUG][.../Thruk/Utils/Timezone.pm:59] server timezone: America/New_York (from ENV)
[10:15:53,832][DEBUG][.../Thruk/Utils/Timezone.pm:59] server timezone: America/New_York (from ENV)
[10:15:53,991][DEBUG][.../Thruk/Utils/Timezone.pm:59] server timezone: America/New_York (from ENV)
[10:15:54,145][DEBUG][.../Thruk/Utils/Timezone.pm:59] server timezone: America/New_York (from ENV)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions