summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2016-11-22 13:03:55 -0500
committerScott Moser <smoser@brickies.net>2016-11-22 13:03:55 -0500
commit4f0a2774b5e71fdc83553de7d563f7bc3db74866 (patch)
treef3bf580c70d39a1253c4aef49287d81628ed3e09
parent677b85abfb2558207956a199eaaceb91af07c076 (diff)
downloadvyos-cloud-init-4f0a2774b5e71fdc83553de7d563f7bc3db74866.tar.gz
vyos-cloud-init-4f0a2774b5e71fdc83553de7d563f7bc3db74866.zip
main: set TZ in environment if not already set.
If TZ is not set in environment, then datetime.datetime() will stat /etc/localtime on every usage. datetime is used in the logging path of cloud-init, and as such this is very busy. During a normal cloud-init boot, it results in we roughly 400+ stat calls to /etc/localtime. The value we set is :/etc/localtime, which is described at https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html See also merge proposal at 307722 for more background. https://code.launchpad.net/~raharper/cloud-init/+git/cloud-init/+merge/307722
-rw-r--r--cloudinit/cmd/main.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/cloudinit/cmd/main.py b/cloudinit/cmd/main.py
index fe37075e..26c02401 100644
--- a/cloudinit/cmd/main.py
+++ b/cloudinit/cmd/main.py
@@ -694,4 +694,6 @@ def main(sysv_args=None):
if __name__ == '__main__':
+ if 'TZ' not in os.environ:
+ os.environ['TZ'] = ":/etc/localtime"
main(sys.argv)