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

Something is broken in TZ... #10

Closed
simonmicro opened this issue Oct 13, 2021 · 9 comments · Fixed by #13
Closed

Something is broken in TZ... #10

simonmicro opened this issue Oct 13, 2021 · 9 comments · Fixed by #13
Assignees
Labels
bug Something isn't working

Comments

@simonmicro
Copy link

:) I'm already on the next point, no tz defined in python possibly... still investigating. thanks to the nice logs, it should be easy to pinpoint.

Originally posted by @edgd1er in #3 (comment)

@simonmicro
Copy link
Author

simonmicro commented Oct 13, 2021

something like this might be required to define TZ in the entrypoint, still working on it....

#Change timzeone if set
[[ -n ${TZ} ]] && [[ -f /usr/share/zoneinfo/${TZ} ]] && [[ -w /etc/localtime ]] && ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime
#use UTC if not
[[ ! -f /etc/localtime ]] && ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime

-> #3 (comment)

@simonmicro simonmicro self-assigned this Oct 13, 2021
@simonmicro simonmicro added the bug Something isn't working label Oct 13, 2021
@edgd1er
Copy link

edgd1er commented Oct 13, 2021

well,

That should be ok, provided TZ was defined as env var.

#Change timzeone if set
[[ "DEBUG" == ${LOGLEVEL} ]] && ls -al /etc/localtime
if [[ -n ${TZ} ]] && [[ -f /usr/share/zoneinfo/${TZ} ]]; then
  # if file is RO then skip.
  if [[ ! -f /etc/localtime ]] || [[ -w /etc/localtime ]]; then
    ln -fs /usr/share/zoneinfo/${TZ} /etc/localtime
  fi
fi
#use UTC if not
[[ ! -f /etc/localtime ]] && ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime

@simonmicro
Copy link
Author

Hey, could you post the error logs? These are my logs (therefore non-critical):

                                   _mnPad: {12}
                                   mnPad: {b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}

/usr/lib/python3.8/site-packages/tzlocal/unix.py:164: UserWarning: Can not find any timezone configuration, defaulting to UTC.
  warnings.warn('Can not find any timezone configuration, defaulting to UTC.')
Wed, 13 Oct 2021 20:07:33 INFO     Machine Name: H6kuYYI1nXxaPuxOvbZ1IJS3LD4444fSwHbMuZ5p43G0aN

@edgd1er
Copy link

edgd1er commented Oct 13, 2021

kms       |                                    mnPad: {b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
kms       |                                    00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
kms       |                                    00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'}
kms       | 
kms       | /usr/lib/python3.9/site-packages/tzlocal/unix.py:164: UserWarning: Can not find any timezone configuration, defaulting to UTC.
kms       |   warnings.warn('Can not find any timezone configuration, defaulting to UTC.')
kms       | Wed, 13 Oct 2021 19:43:45 WARNING  With count = 26, activated client could be detected as not genuine !
kms       | Wed, 13 Oct 2021 19:43:45 INFO     Machine Name: l2i4VortWdGJbbyReaK7tWrKq6jnr

if /etc/localtime is not defined, you have these lines.
As a temporary fix, you can mount your local localtime: -v /etc/localtime:/etc/localtime:ro

the bash snipped should/could be added in the entrypoint when still running as root.( root privileges needed to change /etc/ content)

PS: i'm always using a container to run py-kms.

@Matthew-Beckett
Copy link
Collaborator

I will need to add this as a fix to the Helm chart

@simonmicro
Copy link
Author

I worked-around it in the base docker image. Please try the newest version and feel free to reopen this issue in case that didn't work.

@edgd1er
Copy link

edgd1er commented Oct 14, 2021

Well, it would be nice to have the TZ based on a ENV variable.

@simonmicro
Copy link
Author

I tried that, but any TZ var was ignored by the build-in library. Ofc we could try to respect an environment variable in py-kms, so feel free to implement it :)

@edgd1er
Copy link

edgd1er commented Oct 14, 2021

I have TZ ok (through env var)+ log for client on stdout.
I try to change now uid/gid of user as I need to have specific id/gid on mounted volume and drop root privileges after having set TZ and UID/GID.. without any luck til now. I might have to split entrypoint in 2. My fork might be already to different from yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants