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

Add support for timezone #69

Open
gmenuel opened this issue Sep 23, 2022 · 1 comment
Open

Add support for timezone #69

gmenuel opened this issue Sep 23, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@gmenuel
Copy link

gmenuel commented Sep 23, 2022

Use Case

Currently the patch window use the local time of the node. In our server parc we have servers configured with different timezones, but we would like to have the updates trigger at around the same times.

Describe the Solution You Would Like

Add a timezone field in the patch schedules, and maybe also a daylight saving time field to allow accounting for DST.

@gmenuel gmenuel added the enhancement New feature or request label Sep 23, 2022
@kreeuwijk
Copy link
Contributor

Today the module uses the value of the patching_as_code_utc_offset fact to correct the server-side is_patchday() calculation with the node's offset compared to UTC time. This was specifically added because the server is determining if a certain day is patch day, not the node.

In earlier versions of this module, this calculation was not adjusted for the node's timezone and would cause a logic problem that made the node skip its patch window altogether under certain circumstances. For example, let's imagine:

  • A node that is 6 hours behind the Puppet server. Like a node in New York with a server in London.
  • Say you configure the patch window to occur at the 3rd Friday of the month, between 22:30 and 23:30 hours
  • On that 3rd friday, the is_patchday() function on the server in London will return true during the day, and the node will receive instructions to patch, but with a schedule limiting the resources to be applied only between 22:30 and 23:30 hours local time.
  • At 18:00 hours local time in New York, the server in London reaches midnight and transitions to Saturday. Now, the is_patchday() function on the server no longer returns true and the node in New York stops receiving patch instructions altogether. As a result, the node never gets patched.

This is why the module is required to use the local time of the node in all cases. In order to achieve what you want, you will need to create additional patch schedules (one for each supported timezone), and set the local patching window in accordance to your timezone-adjusted moment of patching. In extreme cases, this can mean that the patch schedule for some timezones can be a day earlier or later. Be careful with doing that in the first/last week of the month though, as sometimes there is no "5th Friday of the month" for example.

So for the example above, you can achieve patching during 22:30-23:30 UK time in New York by using a separate patch schedule for the New York servers like so:

patching_as_code::patch_schedule:
  new_york_primary:
    day_of_week:   Saturday
    count_of_week: 3
    hours:         16:30 - 17:30
    max_runs:      2
    reboot:        ifneeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants