Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default timezone in the origin container #25

Closed
jorgemoralespou opened this issue Oct 10, 2016 · 4 comments
Closed

Set default timezone in the origin container #25

jorgemoralespou opened this issue Oct 10, 2016 · 4 comments

Comments

@jorgemoralespou
Copy link
Contributor

So that logs display the same way as your hosts time.

@bjartek
Copy link
Contributor

bjartek commented Oct 15, 2016

What kinds of logs is the problem here and how do i access them?

@jorgemoralespou
Copy link
Contributor Author

Any logs. If you log into a container and do time, and you do time outside the container in your host, you'll get different TimeZone, so basically when you do a build (as an example) and then you see the logs, the time you'll see is not what you would expect.

There's a way to pass env variables to the container when it starts, and I think that all we need to do is set TZ='whateverTZ_you_are', for example, in my case would be, TZ='Europe/Madrid'

With TZ set:

[jmorales@mac-santander ~] $date
Sat Oct 15 22:55:36 CEST 2016
[jmorales@mac-santander ~] $oc-cluster ssh
Going into the Origin Container
[root@moby origin]# date
Sat Oct 15 22:55:41 CEST 2016

Without TZ set:

[jmorales@mac-santander ~] $date
Sat Oct 15 22:57:12 CEST 2016
[jmorales@mac-santander ~] $oc-cluster ssh
Going into the Origin Container
[root@moby origin]# date
Sat Oct 15 20:57:17 UTC 2016

Ideally, we should get TZ from the host the cluster is running, and letting override by user if they want.

@bjartek
Copy link
Contributor

bjartek commented Oct 19, 2016

If we just want the correct time when connecting to origin we could always do

docker exec -it origin /bin/bash -c "export TZ='Europe/Oslo' && /bin/bash"

We could find the tz this way. From http://stackoverflow.com/questions/12521114/getting-the-canonical-time-zone-name-in-shell-script

if [ -f /etc/timezone ]; then
OLSONTZ=cat /etc/timezone
elif [ -h /etc/localtime ]; then
OLSONTZ=readlink /etc/localtime | sed "s/\/usr\/share\/zoneinfo\///"
else
checksum=md5sum /etc/localtime | cut -d' ' -f1
OLSONTZ=find /usr/share/zoneinfo/ -type f -exec md5sum {} \; | grep "^$checksum" | sed "s/.*\/usr\/share\/zoneinfo\///" | head -n 1
fi

echo $OLSONTZ

@jorgemoralespou
Copy link
Contributor Author

Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants