bazel-remote icon indicating copy to clipboard operation
bazel-remote copied to clipboard

fix: don't use UTC as default timezone

Open shubhindia opened this issue 3 years ago • 5 comments

Using UTC as a default timezone gives incorrect time for others. Instead use local timezone.

Before:

❯ date
Mon Jul 11 10:25:46 IST 2022
❯ go run main.go --config_file config.yaml
2022/07/11 04:55:54 bazel-remote built with go1.18.3.
2022/07/11 04:55:54 Initial RLIMIT_NOFILE cur: 65535 max: 65535
2022/07/11 04:55:54 Setting RLIMIT_NOFILE cur: 65535 max: 65535
2022/07/11 04:55:54 Limiting concurrent file removals to 3000
2022/07/11 04:55:54 Loading existing files in /Users/shubhamgopale/Desktop/Work/Infra/bazel-remote/test_cache.
2022/07/11 04:55:54 Sorting cache files by atime.
2022/07/11 04:55:54 Building LRU index.
2022/07/11 04:55:54 Finished loading disk cache files.
2022/07/11 04:55:54 Loaded 0 existing disk cache items.
2022/07/11 04:55:54 Authentication: disabled
2022/07/11 04:55:54 Mangling non-empty instance names with AC keys: disabled
2022/07/11 04:55:54 gRPC AC dependency checks: disabled
2022/07/11 04:55:54 experimental gRPC remote asset API: disabled
2022/07/11 04:55:54 Starting gRPC server on address 0.0.0.0:9093
2022/07/11 04:55:54 Starting HTTP server on address 0.0.0.0:9092
2022/07/11 04:55:54 HTTP AC validation: enabled
^Csignal: interrupt

After:

❯ go run main.go --config_file config.yaml
2022/07/11 10:26:13 bazel-remote built with go1.18.3.
2022/07/11 10:26:13 Initial RLIMIT_NOFILE cur: 65535 max: 65535
2022/07/11 10:26:13 Setting RLIMIT_NOFILE cur: 65535 max: 65535
2022/07/11 10:26:13 Limiting concurrent file removals to 3000
2022/07/11 10:26:13 Loading existing files in /Users/shubhamgopale/Desktop/Work/Infra/bazel-remote/test_cache.
2022/07/11 10:26:13 Sorting cache files by atime.
2022/07/11 10:26:13 Building LRU index.
2022/07/11 10:26:13 Finished loading disk cache files.
2022/07/11 10:26:13 Loaded 0 existing disk cache items.
2022/07/11 10:26:13 Authentication: disabled
2022/07/11 10:26:13 Mangling non-empty instance names with AC keys: disabled
2022/07/11 10:26:13 gRPC AC dependency checks: disabled
2022/07/11 10:26:13 experimental gRPC remote asset API: disabled
2022/07/11 10:26:13 Starting gRPC server on address 0.0.0.0:9093
2022/07/11 10:26:13 Starting HTTP server on address 0.0.0.0:9092
2022/07/11 10:26:13 HTTP AC validation: enabled
^Csignal: interrupt

Signed-off-by: Shubham Gopale [email protected]

shubhindia avatar Jul 11 '22 04:07 shubhindia

Related to https://github.com/buchgr/bazel-remote/issues/564#issuecomment-1179968269

shubhindia avatar Jul 11 '22 05:07 shubhindia

Hmm, I'll have to think this through a bit since it might be a confusing change for users who currently assume that the log times are shown in UTC. Would it be sufficient for your needs if the log lines were printed with the timezone somehow?

mostynb avatar Jul 11 '22 21:07 mostynb

From whatever things I have used, logs are always printed in default time zone, rather than a fixed one. I don't know the reason behind having UTC timezone as a default one. It's just, when we are looking at the logs, we shouldn't have to read and convert the time to local timezone and then try to understand what is happening. I wonder why no-one reported this before 🤔. But TBH, I would love to have log time in default timezone, makes it a bit less confusing while reading the log.

shubhindia avatar Jul 12 '22 05:07 shubhindia

Sorry it has taken me a while to get back to you. I think this is a reasonable feature request, but I think we need to make this a configuration option and make UTC the default setting to not quietly break some users existing setups.

Brainstorming a bit, would --log-timezone with possible values UTC (default) and local be sufficient? That way other timezones could be chosen by using --log-timezone=local and setting the TZ environment variable where bazel-remote is run.

mostynb avatar Jul 20 '22 16:07 mostynb

Yup, that seems like a reasonable approach. Will push the necessary changes.

shubhindia avatar Jul 20 '22 16:07 shubhindia

Would you like some help with finishing this off?

mostynb avatar Dec 07 '22 20:12 mostynb

Got caught up in other things. Will try to get this done by this weekend or else you can pick it up if you have enough spare time.

shubhindia avatar Dec 08 '22 04:12 shubhindia

Thanks- I squashed this and then added a few followup commits before landing it on the master branch.

mostynb avatar Dec 11 '22 22:12 mostynb