On May 13, 2015, at 3:44 PM, Thomas Segismont <tsegismo@redhat.com> wrote:

Le 13/05/2015 21:11, Stefan Negrea a écrit :
Hello Everybody,

With the metrics aggregation work well under way, we have encountered the first case where timezones are important. The task queue [1] that John wrote to be used in the aggregation process is time sensitive. The tasks ran according to a schedule that is predefined; the time relationship also applies to failures, retries, and cancellation. Based on the experience we had with RHQ, not using an UTC timezone can lead to errors and loss of data (for more details visit [2])

I propose to set the default time zone for all the services to UTC. Only allow the concept of a timezone in the UI. This will avoid any problems due to automatic transitions between DST and non-DST times. For example, if the user wants to schedule something 2 weeks from now, let the UI handle the user selection. But when the user action is sent to the backend, it should be expressed in an timezone agnostic manner (eg. milliseconds since Unix Epoch).

The PR [1] sets the default timezone for the JODA library to be UTC for the classloader that contains the metrics service. With the recent discussions about creating a combined Kettle EAR or using a single classloader, that means this setting will extend to all the services in the same classloader that use JODA. And this is just the default, if a service really needs to set another timezone for a date object, it can be done by just specifying the timezone.

We tried to make the change more local in the metrics code, but the approach was error prone. Anybody could make a mistake and instantiate a date object in the current server timezone rather than UTC. This global approach drastically limits inadvertent mistakes.

Two questions for the group:
1) Does anybody see any issues with using the UTC timezone as default at the services layer?

I think it is error prone to have any joda.Date you create set in the 
UTC timezone, and any util.Date you create in the server timezone.

Also I can't see where the problem to create the joda.Instant objects 
properly in the scheduler utility class. Maybe I'm missing something?

The challenge is that the time zone configuration is not just limited to a single class. Right now there are only a few places where DateTime objects are created and where the time zone needs to be set. AS the task scheduler code grows, the number of places where we have to worry about configuring the time zone may as well. I think that there are good arguments being made for and against the global setting. 

The one thing I ask right now though is whether we are ok with merging the branch into master while this discussion is ongoing. If we decide that changes are needed, they can be made after the merge. Right now other work is going to be held up until the task-queue branch gets merged.

2) Should we expand this setting to the JVM (not just JODA)?


To make this properly the JVM must be started with user.timezone 
property set to UTC. Otherwise we don't control what happens at the 
server level or in libraries, because the setting is effective only when 
the class is loaded.
In the end, the system would rely on external config.

Also if we do this, it means than most users will have to configure all 
the loggers template, because you usually want your logs printed in the 
timezone of your hosts, but the default templates will print the logs 
for the JVM timezone.

I fear it's not the only annoyance which would show up.

[1] Task queue PR  - https://github.com/hawkular/hawkular-metrics/pull/205
[2] Old RHQ thread - https://lists.fedorahosted.org/pipermail/rhq-devel/2014-November/003709.html

Thank you,
Stefan Negrea

Software Engineer

hawkular-dev mailing list

hawkular-dev mailing list