On Tue, 12 Sep 2017 22:24:08 +1000 "Bruce Zhang" brucezhang2010@gmail.com wrote:
It's really wired. I have changed time_zone in nav.conf and all time is correct on the front page.
But only the Service state alert's start time and end time is showing in UTC timezone.
I think this problem is easily explained, and potentially easily fixed.
The timezone setting in `nav.conf` only applies to timestamps generated in Python code.
However, the component that produces serviceState alerts, servicemon, doesn't generate the timestamps in Python code. Servicemon is one of the oldest pieces of code in NAV (pre Django-era), and uses pure SQL to insert events into the database. It hands the timestamp generation over to PostgreSQL itself, which means that the timezone is decided by PostgreSQL, not by NAV.
I guess the easy fix would be to have servicemon produce an explicit timestamp to insert, instead of leaving it up to PostgreSQL.
All timestamp fields in NAV's PostgreSQL schema use the `TIMESTAMP WITHOUT TIME ZONE` data type. The more complicated (and probably more long-term) solution to problems like this would be to change all those fields to `TIMESTAMP WITH TIME ZONE`.
I'm out travelling atm; I suggest reporting this bug at [1], so we don't forget about it :)
[1] https://github.com/UNINETT/nav/issues/new