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

build: load time/tzdata on Windows #18676

Merged
merged 2 commits into from
Oct 6, 2023
Merged

build: load time/tzdata on Windows #18676

merged 2 commits into from
Oct 6, 2023

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented Oct 5, 2023

Nomad uses time.LoadLocation() to translate a periodic job time zone string value to a time.Location. From godocs:

LoadLocation looks for the IANA Time Zone database in the following locations in order:

* the directory or uncompressed zip file named by the ZONEINFO environment variable
* on a Unix system, the system standard installation location
* $GOROOT/lib/time/zoneinfo.zip
* the time/tzdata package, if it was imported

So non-Unix systems require Go to be installed or time/tzdata to be imported, otherwise running periodic jobs with a specific time_zone value results in an error:

Invalid time zone "America/Toronto": unknown time zone America/Toronto

This commit adds the timetzdata build tag on Windows to embed the time zone data into the final binary. This results in a slightly bigger binary, but from time/tzdata godocs:

Importing this package will increase the size of a program by about 450 KB.
[..]
This package will be automatically imported if you build with -tags timetzdata.

Closes #18578

Nomad uses `time.LoadLocation()` to translate a periodic job time zone
string value to a `time.Location`. From godocs:

    LoadLocation looks for the IANA Time Zone database in the following locations in order:

    * the directory or uncompressed zip file named by the ZONEINFO environment variable
    * on a Unix system, the system standard installation location
    * $GOROOT/lib/time/zoneinfo.zip
    * the time/tzdata package, if it was imported

So non-Unix systems require Go to be installed or `time/tzdata` to be
imported, otherwise running periodic jobs with a specific `time_zone`
value results in an error:

    Invalid time zone "America/Toronto": unknown time zone America/Toronto

This commit adds the `timetzdata` build tag on Windows to embed the time
zone data into the final binary. This results in a slightly bigger
binary, but from `time/tzdata` godocs:

    Importing this package will increase the size of a program by about 450 KB.
    [..]
    This package will be automatically imported if you build with -tags timetzdata.
@lgfa29 lgfa29 added backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line backport/1.6.x backport to 1.6.x release line labels Oct 5, 2023
@lgfa29
Copy link
Contributor Author

lgfa29 commented Oct 5, 2023

Here's an example of running a periodic job with binaries that have and don't have the time zone data embedded:

image

Copy link
Member

@gulducat gulducat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/1.4.x backport to 1.4.x release line backport/1.5.x backport to 1.5.x release line backport/1.6.x backport to 1.6.x release line
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add time zone data for Windows
2 participants