Zwavejs2mqtt: [bug] logging doesn't respect containers time / time zone settings

Created on 15 Feb 2021  路  8Comments  路  Source: zwave-js/zwavejs2mqtt

Before submitting a bug please read:

Version

App Version
1.1.1+94ff7ed.94ff7ed

Zwavejs Version
6.3.0-8f22052

Build/Run method

  • [X] Docker
  • [ ] PKG
  • [ ] Manually built (git clone - npm install - npm run build )

Describe the bug

I use the following in docker-compose to ensure the containers time matches the host.

    volumes:
      - ./store:/usr/src/app/store
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro

This is correctly setting the date and time inside the container - confirmed by attaching to container and issuing the date command.

However logs now seem to be in UTC rather than local time.
This was working on 6.2.0 and 1.1.0

To Reproduce

Steps to reproduce the behavior:

  1. set host to have a TZ of not UTC (e.g. LosAngeles)
  2. build docker image from source with both branches as master
  3. ensure time is mapped as described above
  4. on host use date command and note time
  5. start container and attach to it with docker exec -it zwavejs2mqtt /bin/bash
  6. in container use date command - time should match host time
  7. use tail -f zwavejs_1.log - logs are in UTC time.

Expected behavior

Logs should be in local time as per previous builds, this appears to be regression.

Additional context

Previous working scenario was with pre-built docker hub master image, not ones i have built using the provided docker contrib file..

bug

Most helpful comment

I think using the TZ variable is not only a workaround, but the correct solution. :-)

All 8 comments

hmm adding this worked (as it is another solution to TZ)

What I don't get is why this wasn't needed on the containers for the last week or so, but is now.
I will retest once next official dockerhub master comes out and see if it is new behavior or dependent on build process.
Unless how logging picks it time was changed recently in a commit - aka it used to use the containers time but now it explicitly looks for the TZ env var?)

    environment:
      - TZ=America/Los_Angeles

The TZ var has always been there in Docker containers

i know, i think i didn't explain myself

The TZ is a fine workaround to a regression i am observing.
On master container from 4 days ago
```
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
````
works to set time zone for container AND logging was using this time

on the containers i built using Dockerfile.contrib it works to set the timezone in the container but logging ignores container time and uses UTC.

on the containers i built using Dockerfile.contrib it works to set the timezone in the container but logging ignores container time and uses UTC.

That file is to build images for testing purposes and it's not really maintained, @larstobi look at this if you want/have time, nothing so important btw :)

I think using the TZ variable is not only a workaround, but the correct solution. :-)

coo & thanks, glad i got an explanation :-), i don't need it to work in the contrib built images.

@larstobi i like the file mapping as in a pre-defined docker-compose it works for just about every linux system without need for folks to go find their TZ variable format (and we have a lot of beginners coming through - like me)

but happy to snap to TZ as that seems to be the consensus, i can add TZ to our example docker-compose in the repo if that works for folks?

i can add TZ to our example docker-compose in the repo if that works for folks?

Great idea! 馃槉

@scyto Go for it! Thanks :)

Was this page helpful?
0 / 5 - 0 ratings