← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~raharper/cloud-init:systemd_export_tz into cloud-init:master


On Fri, Nov 4, 2016 at 4:08 AM, Scott Moser <smoser@xxxxxxxxxx> wrote:

> Are hyou sure it wouldn't fix it?
> changing os.environ should change the environment of the process that is
> running, which (I'd think) would have the same result.  Unless python is
> doing all those stats before we could set it (it may well do some).

updating os.environ will help in that cloud-init drives lots of python
logging with timestamps.  However, there are other modules which may run as
forked processes under our unit which will NOT have it; and it's literally
any program making the glibc call.

> I couldn't reproduce any difference with set or unset with a simple
> program like this:
> import os, time
> if 'TZ' not in os.environ:
>     os.environ['TZ'] = ":/etc/localtime"
> print(time.strftime("%a, %d %b %Y %T %z"))
> And then running with:
>   env -i TZ strace python program.py

 (foudres) ~ % env -i strace /usr/bin/python3 -c 'import os; from datetime
import datetime; print(datetime.now())' 2>&1 | egrep
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2221, ...}) = 0
stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2221, ...}) = 0

(foudres) ~ % strace /usr/bin/python3 -c 'import os; from datetime import
datetime; print(datetime.now())' 2>&1 | egrep
open("/usr/share/zoneinfo/America/Chicago", O_RDONLY|O_CLOEXEC) = 3

> I'm not opposed to this, and dont want to discount the performance
> improvement, but if we can do it in a single place, i'd rather that then in
> multiple systemd files which would only benefit systemd.

cloud-init can write a single EnvironmentFile= and we can specify that in
each Unit file
showed this here and Steve and Martin were interested in having that maybe
set as systemd default.

however, for cloud-init which may run in *other* distro environments with
systemd, we really should bring our own.

> --
> https://code.launchpad.net/~raharper/cloud-init/+git/
> cloud-init/+merge/307722
> You are the owner of ~raharper/cloud-init:systemd_export_tz.

Your team cloud init development team is requested to review the proposed merge of ~raharper/cloud-init:systemd_export_tz into cloud-init:master.