Bug 709211 - System clock with local time zone incorrectly interpreted
Summary: System clock with local time zone incorrectly interpreted
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: systemd
Version: 15
Hardware: x86_64
OS: Unspecified
unspecified
medium
Target Milestone: ---
Assignee: systemd-maint
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 704050 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-05-31 05:29 UTC by Michal Piotrowski
Modified: 2012-05-29 04:06 UTC (History)
21 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-01-24 14:05:27 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Michal Piotrowski 2011-05-31 05:29:15 UTC
Description of problem:
The time is always incorrect after booting Fedora when system clock uses local time zone. It looks like the system always treats computer's clock as an UTC clock during the boot in spite of unchecked "System clock uses UTC".

Version-Release number of selected component (if applicable):
system-config-date-1.9.61-2.fc15.noarch

(I am not sure if this is the correct component for this bug).

How reproducible:
Always

Steps to Reproduce:
1. Computer clock should use local time zone different than UTC.
2. "System clock uses UTC" setting is unchecked.
3. Boot Fedora.
  
Actual results:
Incorrect system time after booting Fedora and before ntp synchronization.

Expected results:
Correct system time even without ntp synchronization.

Additional info:
See this forum thread: http://forums.fedoraforum.org/showthread.php?t=263678

Comment 1 Nils Philippsen 2011-05-31 10:25:09 UTC
System-config-date correctly sets whether to set the system clock to UTC or not in /etc/adjtime. This setting is evaluated in hwclock-load.service (from systemd-units) at bootup, changing component.

Comment 2 Sam Varshavchik 2011-05-31 23:41:58 UTC
I am seeing the same bug, America/New_York.

Comment 3 Tom Horsley 2011-05-31 23:56:04 UTC
I wonder if the default timezone isn't known during some part of the new systemd boot, so it thinks local and utc are the same when it is fiddling with the clock?

Comment 4 Sam Varshavchik 2011-06-01 01:29:33 UTC
I think this bug needs to be reassigned to systemd-units. I believe that this is a bug in the systemd-units %post script when upgrading from F14 to F15. 

The bug is that hwclock-load.service never gets enabled when upgrading
systemd-units-10-2.fc14.1.x86_64 to systemd-units-26-2.fc15.i686.

%post in systemd-units-26-2.fc15.i686 reads as follows:

if [ $1 -eq 1 ] ; then

# ....

        /bin/systemctl enable \
                getty@.service \
                remote-fs.target \
                systemd-readahead-replay.service \
                systemd-readahead-collect.service \
                hwclock-load.service > /dev/null 2>&1 || :
fi

This, of course, never gets executed when upgrading from F14. This gets executed only when installing systemd-units for the first time as part of a fresh install. The %post in F14's systemd-units did not enable hwclock-load.service -- looks like this was what was overlooked initially, it got fixed somewhere along the way, but existing F14 systems being upgraded to F15 do not get the benefit of the fix, because it never gets executed.

The fix is to manually run the above command, fix the clock for the last time, and reboot.

Comment 5 Sam Varshavchik 2011-06-01 01:40:46 UTC
You can ignore the arch disrepancy, I was compared an F14 x86_64 machine with what I've got on an F15 i386 laptop. Fairly sure that this is the bug. After rebooting a few times, the clock came up with the correct local time, each time, now.

Comment 6 Nils Philippsen 2011-06-01 08:39:48 UTC
(In reply to comment #4)
> I think this bug needs to be reassigned to systemd-units. I believe that this
> is a bug in the systemd-units %post script when upgrading from F14 to F15. 

Oh, I meant to change the component of this bug to systemd (which is the main package of systemd-units) above in comment #1. Changing now.

> The bug is that hwclock-load.service never gets enabled when upgrading
> systemd-units-10-2.fc14.1.x86_64 to systemd-units-26-2.fc15.i686.
> 
> %post in systemd-units-26-2.fc15.i686 reads as follows:
> 
> if [ $1 -eq 1 ] ; then
> 
> # ....
> 
>         /bin/systemctl enable \
>                 getty@.service \
>                 remote-fs.target \
>                 systemd-readahead-replay.service \
>                 systemd-readahead-collect.service \
>                 hwclock-load.service > /dev/null 2>&1 || :
> fi
> 
> This, of course, never gets executed when upgrading from F14. This gets
> executed only when installing systemd-units for the first time as part of a
> fresh install. The %post in F14's systemd-units did not enable
> hwclock-load.service -- looks like this was what was overlooked initially, it
> got fixed somewhere along the way, but existing F14 systems being upgraded to
> F15 do not get the benefit of the fix, because it never gets executed.

I concur with that for some reason or another, the hwclock-load  and other services weren't enabled, but I don't think it's because $1 would evaluate to anything other than 1 in the case of upgrading F-14 (which doesn't have a systemd-units package) to F-15.

RPM is rather simplistic here, $1 means just "how many packages of this name (systemd-units) are installed after this part of the transaction (installation of the new version-release in the case of an update) is finished", see http://fedoraproject.org/wiki/Packaging/ScriptletSnippets#Syntax for details. It doesn't care if the package is installed because it obsoletes an older one of a different name (which is what we have here in the case of an upgrade with a SysV->systemd migration).

I'm unsure why these services weren't enabled when installing the package, though. The only other reason I can think of why $1 could be != 1 is if systemd-units were installed twice, but then at one point the first instance must have been installed and $1 would have been 1 in its %post script. To me, that leaves a systemd-units version that didn't have this %post script while being installed for the first time, e.g. when upgrading from F-14 to a prerelease or Rawhide which had systemd < 14 (which is were the hwclock-load service was enabled for the first time). Did you see this issue with an upgrade from F-14 to F-15 proper, or was the upgrade done to a pre-release?

> The fix is to manually run the above command, fix the clock for the last time,
> and reboot.

Technically, that's only a workaround ;-).

Comment 7 Sam Varshavchik 2011-06-01 11:03:23 UTC
If F14 did not have systemd-units, then where did this come from:

[mrsam@shorty ~]$ rpm -q -i systemd-units
Name        : systemd-units                Relocations: (not relocatable)
Version     : 10                                Vendor: Fedora Project
Release     : 2.fc14.1                      Build Date: Tue 05 Oct 2010 06:47:38 PM EDT
Install Date: Fri 22 Oct 2010 02:30:57 PM EDT      Build Host: x86-15.phx2.fedoraproject.org
Group       : System Environment/Base       Source RPM: systemd-10-2.fc14.1.src.rpm
Size        : 244036                           License: GPLv2+
Signature   : RSA/SHA256, Wed 06 Oct 2010 02:26:15 PM EDT, Key ID 421caddb97a1071f
Packager    : Fedora Project
URL         : http://www.freedesktop.org/wiki/Software/systemd
Summary     : Configuration files, directories and installation tool for systemd
Description :
Basic configuration files, directories and installation tool for the systemd
system and session manager.

F14 did have systemd-units. Therefore, on upgrade $1=2, and that's why hwclock-load.service was not enabled.

This was an upgrade from F14 proper to F15.

Comment 8 Nils Philippsen 2011-06-01 11:58:32 UTC
That would explain it:

- F-14 was planned to be the first Fedora version to have systemd instead of upstart. This was changed shortly prior to release.
- Even though systemd wasn't offered in the installer (on account of not being listed in comps.xml), packages of an old version of systemd (10) were in the repository.

I guess that you either installed a prerelease of F-14 which still had systemd per default and updated to F-14 proper later, or installed systemd manually on your F-14 system. Is that the case?

Comment 9 Sam Varshavchik 2011-06-01 13:01:14 UTC
This machine was installed from an F14 live image that I torrented off fedoraproject.org, post F14 release.

Was systemd-units present in the released F14 live image? Or did I somehow end up getting a prerelease F14 live image?

Comment 10 Nils Philippsen 2011-06-01 13:42:22 UTC
(In reply to comment #9)
> Was systemd-units present in the released F14 live image? Or did I somehow end
> up getting a prerelease F14 live image?

I've just checked this: the live image indeed included the systemd-units package (but not any other systemd packages). This leaves the question how these services could be enabled during upgrade from systemd-units<=13 to a later version...

A rather hackish way would be to check for the existence of the affected service unit files in the %pre scriptlet, then set a flag (a file) which is checked for and removed in %post (instead of $1==1) to enable the services, this would ensure that they are enabled only when the package is installed or being updated from a version that doesn't have these unit files (read: is too old).

Lennart, what do you think?

Comment 11 Michal Piotrowski 2011-06-01 14:16:39 UTC
systemd packages are also on DVD installer of Fedora 14. I was doing clean install of F14 from DVD than I have upgraded it to F15.

Comment 12 Sam Varshavchik 2011-06-01 14:46:11 UTC
You can use a triggerpostun on version < version with the trigger.

Comment 13 Nils Philippsen 2011-06-01 14:51:41 UTC
(In reply to comment #12)
> You can use a triggerpostun on version < version with the trigger.

Yes, much less hackish and one of the few cases where using a trigger poses less risk of shooting oneself in the foot than doing it differently :-).

Comment 14 Sergei LITVINENKO 2011-06-07 18:41:24 UTC
I met the same bug after some update (maybe yesterdays) of fresh installed fedora-15 (Fedora-15-i386-DVD.iso is used). Workaround is to set 'System clock uses UTC'


[sergeil@ua-dudn000 etc]$ rpm -qf `which system-config-date `
system-config-date-1.9.61-2.fc15.noarch

Comment 15 A. Mani 2011-06-10 17:07:59 UTC
The problem happens even for fresh installs of F15 (x86-64) with /home from F14.
Hardware clock is set to local time (IST). I had filed bugs earlier.

Comment 17 Panos Kavalagios 2011-06-16 21:04:31 UTC
All my PCs/laptops upgraded from F14 are affected by this bug. It is not clear to me what is the resolution or a quick fix for this irritating bug. Does it need to re-install systemd-units or to enable hwclock-load.service service?

Comment 18 Michal Schmidt 2011-06-17 07:30:45 UTC
(In reply to comment #17)
> Does it need to re-install systemd-units

No.

> or to enable hwclock-load.service service?

Yes. Or switch to UTC for the hardware clock.

Comment 19 Adam Williamson 2011-06-21 00:48:53 UTC
we should probably commonbugs this.

Comment 20 Sergei LITVINENKO 2011-06-21 05:53:53 UTC
> enable hwclock-load.service service

do not work for me

Comment 21 Nils Philippsen 2011-06-21 08:25:49 UTC
(In reply to comment #20)
> > enable hwclock-load.service service
> 
> do not work for me

What command did you use to enable hwclock-load.service?

Comment 22 Sergei LITVINENKO 2011-06-21 17:26:55 UTC
(In reply to comment #21)
> (In reply to comment #20)
> > > enable hwclock-load.service service
> > 
> > do not work for me
> 
> What command did you use to enable hwclock-load.service?

systemctl enable hwclock-load.service

==> and reboot

current status:
===============

[root@ua-dudn00000 etc]# cat adjtime 
-0.619641 1308676102 0.000000
1308676102
LOCAL

[root@ua-dudn00000 etc]# date
Tue Jun 21 17:14:19 EEST 2011

[root@ua-dudn00000 etc]# hwclock --show
Tue Jun 21 20:14:40 2011  -0.954261 seconds

==> right time is hwtime

[root@ua-dudn00000 sysconfig]# grep Kiev *
clock:ZONE="Europe/Kiev"
[root@ua-dudn00000 sysconfig]# cat /etc/sysconfig/clock 
# The time zone of the system is defined by the contents of /etc/localtime.
# This file is only for evaluation by system-config-date, do not rely on its
# contents elsewhere.
ZONE="Europe/Kiev"


[root@ua-dudn00000 sysconfig]# file /etc/localtime 
/etc/localtime: timezone data, version 2, 12 gmt time flags, 12 std time flags, no leap seconds, 119 transition times, 12 abbreviation chars

[root@ua-dudn00000 sysconfig]# ll /etc/localtime 
-rw-r--r--. 2 root root 2057 Mar 30 19:04 /etc/localtime

[root@ua-dudn00000 sysconfig]# systemctl status hwclock-load.service
hwclock-load.service - Apply System Clock UTC Offset
Loaded: loaded (/lib/systemd/system/hwclock-load.service)
Active: active (exited) since Tue, 21 Jun 2011 20:08:43 +0300
Process: 406 ExecStart=/sbin/hwclock --systz (code=exited, status=0/SUCCESS)
CGroup: name=systemd:/system/hwclock-load.service

[root@ua-dudn00000 sysconfig]# systemctl --all | grep clock
hwclock-load.service loaded active   exited  Apply System Clock UTC Offset
hwclock-save.service loaded inactive dead    Update RTC With System Clock

Comment 23 Nicola Soranzo 2011-07-05 22:11:56 UTC
Duplicate of 656747?

Comment 24 Sergei LITVINENKO 2011-08-08 06:44:48 UTC
Can anybody explain how to fix this bug manually? I think, it is not good idea to reinstall system...

Comment 25 Sergei LITVINENKO 2011-08-08 09:18:07 UTC
IMHO, solution is to disable hwclock-load.service `systemctl disable hwclock-load.service`

`hwclock --systz` shift system time according to timezone, but it is not necessary, because local time is already in hwclock.

Nothing to do...

Comment 26 Göran Uddeborg 2011-08-08 17:20:19 UTC
> IMHO, solution is to disable hwclock-load.service

Odd!  For me the problem disappeared when I ENABLED the hwclock-load.service as suggested earlier in this bugzilla.

Comment 27 Anton Guda 2011-08-08 20:44:42 UTC
I found workaround for this bug: build kernel with CONFIG_RTC_DRV_CMOS to 'm', not to 'y'. And it works for me.

Comment 28 Sergei LITVINENKO 2011-08-12 22:08:10 UTC
Fedora-16 preAlpha (guest of KVM) is affected too...

Unfortunately, hwclock-load.service is missed there. By this reason I can not play with it.

Comment 29 Fedora Admin XMLRPC Client 2011-10-20 16:29:29 UTC
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.

Comment 30 Jóhann B. Guðmundsson 2012-01-24 13:44:29 UTC
Is this still a problem or can this bug be closed?

Comment 31 Michal Piotrowski 2012-01-24 14:05:27 UTC
It works for me from so I think the bug can be closed.

Comment 32 Nicola Soranzo 2012-01-24 14:16:41 UTC
Closing as NEXTRELEASE per http://fedoraproject.org/wiki/BugZappers/BugStatusWorkFlow

Comment 33 Nicola Soranzo 2012-01-24 14:18:20 UTC
*** Bug 704050 has been marked as a duplicate of this bug. ***


Note You need to log in before you can comment on or make changes to this bug.