Comment placed inside of /etc/timezone

Bug #1341710 reported by Lenny Gottesman
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Medium
Unassigned
cloud-init (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Greetings!

cloud-init v0.7.5 (trusty) is placing a comment in the /etc/timezone file, when that file isn't intended to contain a comment. This is confusing openjdk (and perhaps other programs?), which is unable to determine the correct timezone.

Sample /etc/timezone from v0.7.5:
----
# Created by cloud-init v. 0.7.5 on Mon, 14 Jul 2014 18:01:38 +0000
US/Eastern
----

Openjdk has been informed of this back in 2012, and decided that they won't change things on their end because comments in /etc/timezone aren't part of the "spec". https://bugs.openjdk.java.net/browse/JDK-7192951. Of course, there is no formal spec for /etc/timezone. The closest that I've seen to a spec is actually contained within the bug report at openjdk:

=====================================================================
I am not sure that a formal spec of /etc/timezone exists. The Debian
tools for manipulating it (tzconfig and tzsetup) do basically the same
thing.

--- reading ---
if [ -L /etc/localtime ] ; then
 current_timezone=$(readlink /etc/localtime | sed 's%^/usr/share/zoneinfo/%%')
elif [ -f /etc/timezone ] && [ -f /etc/localtime ]; then
 current_timezone=$(cat /etc/timezone)
fi

--- setting ---
echo $timezone > /etc/timezone

It is the same in Ubuntu. So, in Debian-based distros it is just a
LF-terminated line, with no spaces and extra characters. To be a
little more general, I suggest ignoring all leading spaces (including
new lines) and then reading consecutive non-space characters.
=====================================================================

For the record, cloud-init previously did not include a comment in /etc/timezone. Would it be possible to revert to the previous behavior of not including a comment in /etc/timezone? A quick skim of the source code tells me that the set_timezone() method would have to be changed to no longer include the line with util.make_header().

Thanks!

Related branches

Revision history for this message
Scott Moser (smoser) wrote :

to recreate, you can either:
a.) launch instance with cloud-config specifying:
    timezone: US/Eastern
b.) inside an instance run:
    sudo cloud-init single --frequency=always --name=cc_timezone US/Eastern

Either way, you'll end up with something like:

$ cat /etc/timezone
# Created by cloud-init v. 0.7.6 on Tue, 29 Jul 2014 13:49:26 +0000
US/Eastern

Changed in cloud-init (Ubuntu):
status: New → Confirmed
importance: Undecided → Medium
Changed in cloud-init:
status: New → Confirmed
importance: Undecided → Medium
Revision history for this message
Scott Moser (smoser) wrote :

fix-committed in revno 988.

Changed in cloud-init:
status: Confirmed → Fix Committed
Changed in cloud-init (Ubuntu):
importance: Medium → Low
Revision history for this message
Scott Moser (smoser) wrote :

I've moved this to low because I looked back, and realized this has been busted in 0.7.X (meaning everything after 12.04), so it wouldn't seem to be high impact.

Revision history for this message
Lenny Gottesman (lenny-launchpad) wrote :

Hi Scott,

Thanks for applying this fix. I really appreciate it.

In case someone arrives here from a google search who has an issue with openjdk selecting an incorrect default timezone, you can work around the issue by specifying the correct default timezone on the command line string like so:

java -Duser.timezone=US/Eastern [ options ] class [ argument ... ]

Best Regards,
Lenny

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package cloud-init - 0.7.6~bzr990-0ubuntu1

---------------
cloud-init (0.7.6~bzr990-0ubuntu1) utopic; urgency=medium

  * debian/README.source: get changelog from trunk when new snapshot
  * New upstream snapshot.
    * add ubuntu-init-switch module for testing systemd.
    * do not put comments in /etc/timezone (LP: #1341710)
 -- Scott Moser <email address hidden> Thu, 31 Jul 2014 15:05:51 -0400

Changed in cloud-init (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
Scott Moser (smoser) wrote :

fixed in 0.7.6

Changed in cloud-init:
status: Fix Committed → Fix Released
Revision history for this message
James Falcon (falcojr) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.