bazel-remote
bazel-remote copied to clipboard
fix: don't use UTC as default timezone
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]
Related to https://github.com/buchgr/bazel-remote/issues/564#issuecomment-1179968269
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?
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.
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.
Yup, that seems like a reasonable approach. Will push the necessary changes.
Would you like some help with finishing this off?
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.
Thanks- I squashed this and then added a few followup commits before landing it on the master branch.