-
Notifications
You must be signed in to change notification settings - Fork 341
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
Feature: libpe_rules: New timezone attribute in date_expression of rules #3068
base: main
Are you sure you want to change the base?
Conversation
ISO 8601 does support time zone offsets, though only hardcoded amounts, not locality strings that can take daylight saving time into account. So there is some question of how the system behaves if both the new field and an ISO 8601 offset are specified (which might just require documenting). We could reduce the scope for conflict by only allowing the locality names in the new field, since ISO 8601 can handle a numeric offset. |
See also #2737 (T188) |
Documenting is probably the way to go. So far I've only skimmed the PR that you linked, but I did notice that our parsing of ISO 8601 strings is um... not robust. For one thing, I think the best scenario would be that our time parsing functions honor whatever ISO 8601-correct timezone a user passes in (whether it does that currently is questionable and probably not reliable), and then the new I'd like to call the parsing fixes out-of-scope. I wanted to mess with our time library as little as possible until the switch to |
The CI failures on FreeBSD are due to something that's not POSIX-compliant in the new sed expressions, unrelated to rules. |
On second thought, I'm not 100% sure whether it is ignored; it might get stored in The parsing in |
Updated to address discussion:
|
ad5d8fa
to
a0952eb
Compare
Oh and rebased on current main... crap, that makes reviewing the actual changes more difficult. |
The thought of a rule in resource defaults using one time zone and a rule for a resource's instance attributes using another seems like trouble. A cluster property has the problem that we'd have to use the system timezone to evaluate the properties themselves. We could possibly do that just to get the timezone then re-evaluate the rest using the configured one, even if that's a bit awkward. Honestly, anyone trying to use rules to put the cluster in one timezone during one time period and a different timezone during another time period deserves whatever happens. A sysconfig variable would still be open to the same problem as using the system timezone, but it would let admins set a cluster time zone separate from the system one. Nothing's ideal, but I'm leaning to a cluster property. |
Yeah, I wouldn't expect it to misbehave though (haven't given it deep thought). It sounds like a bizarre configuration that would behave exactly how the user configured it to. Just don't do that if you don't want the rules to have different time zones.
That was the initial plan and it's probably doable.
100% agreed. Although it still bothers me a tiny bit to knowingly introduce a bug in a corner case.
You wouldn't even need a new sysconfig variable. Just set the |
Yes, but the admin would have to remember to set it whenever creating a new rule (and won't necessarily be the same admin who created earlier rules). It would be a recurring problem.
It wouldn't be a bug, just a documented limitation.
The other downside I forgot to mention above is that the command-line tools don't read sysconfig, so e.g. crm_simulate and crm_rule would give results based on the host timezone regardless of what's in sysconfig. So, probably a cluster property is best. |
Ah that's right, we discussed that in the T646 task I believe |
a0952eb
to
7680f96
Compare
Rebased on current main and dropped test update commit (rather than re-running to fix conflict), no other changes |
Internal-only Signed-off-by: Reid Wahl <[email protected]>
Internal-only Signed-off-by: Reid Wahl <[email protected]>
Internal-only Signed-off-by: Reid Wahl <[email protected]>
crm_time_get_timezone() should convert dt->offset to hours and minutes, rather than converting dt->seconds. Additionally, the output variables must be signed, since the offset can be negative. However, we can't change the interface since it's public API. Create a new internal function to get timezone correctly. Signed-off-by: Reid Wahl <[email protected]>
This function has never worked correctly (it uses dt->seconds instead of dt->offset, and it stores output values as unsigned). Nothing uses it internally, so we deprecate it here. It will be removed in a future release. Signed-off-by: Reid Wahl <[email protected]>
Given a timezone expressed as hours and minutes offset from UTC, adjust the object's time to match the timezone and then set the object's timezone. Signed-off-by: Reid Wahl <[email protected]>
This will be used as a new cluster property name. Ref T646 Signed-off-by: Reid Wahl <[email protected]>
For the new "timezone" attribute of date_expression elements in rules. Ref T646 Signed-off-by: Reid Wahl <[email protected]>
Closes T646 Closes RHBZ#2183466 Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
7680f96
to
4c24f97
Compare
Rebased on current main, have not implemented |
@kgaillot Alright, I came back to this, thinking it'd be a trivial task before starting my options work on T620 :) There's another wrinkle with implementing this as a property: refreshing the cluster-wide timezone in a running cluster (if it gets updated) is tough. Every daemon needs to use the configured timezone. Aside from any unforeseen side effects that updating it on the fly might have, some daemons aren't yet reading CIB property set at all -- let alone refreshing it after a CIB update. My first thought was "Okay, let's document that We might need to give every daemon a CIB diff callback (similar to In turn, as appealing as it is to knock this out right now, it might be better to wait until T620 is done and the options are more standardized and less redundant. Thoughts? |
Yeah, let's leave this aside for now. It sounds like a sysconfig option would be better, but then it's less helpful since it still has to be set on every node. The only advantage would be to have a "cluster time" that's different from local time. |
As you've reminded me a couple of times, a sysconfig option wouldn't have an effect for CLI tools. |
Ah of course. T574 would be a fix for that, but it would still require setting it separately on each node. |
We could rely on high-level CLI tools (pcs, crmsh) to set the sysconfig variable on all nodes, though that's less appealing. Also semantically, the sysconfig file is best suited for local settings. Most of them don't modify behavior in a meaningful way, and the few that do (node start state and crash handling) are restricted to local effects. Timezone certainly can be a local effect but in the Pacemaker context it'd be ideal to keep it inherently in sync across the cluster, due to things like consistent rule evaluation. Giving the remaining daemons a CIB diff callback that re-reads the CIB properties and sets the relevant options (which would include It has another big downside though, which is that some daemons ( For all its flaws, a |
Yeah I definitely don't want to add CIB connections to new daemons. A better model for the cluster property approach would be to add a new IPC/CPG command to each daemon for setting the timezone, and have the controller use those when necessary. Why would daemons need it though? The scheduler reads it from the input CIB. The executor should probably have it for recording action history, but the others probably don't care. I suppose we could use it for log timestamps but that may be not worth the hassle. If we make it an XML attribute of the |
That might work, just have the controller spread the word to everyone. That would address the issue of updates and of consistency.
Any miscellaneous uses of times (like for displaying output) and for future-proofing. It's not strictly necessary for anything except rule evaluation, but the consistency would be nice.
Oh that's a good thought. I don't know if rule evaluation is actually that big a problem -- just fetch and evaluate the Making it a |
While looking through undocumented environment variables, I found I may remove that variable soon since we only set it and never check it, but that is an idea to keep in mind. |
That variable has been invited to the party many times but never asked to dance :) |
Users can now add a "timezone" attribute to the date_expression element of a rule. The value must adhere to one of the formats for the
TZ
environment variable described in thetzset(3)
man page.If "timezone" is set, the date_expression is evaluated based on it. For example, suppose the system is using the
America/Los_Angeles
(std: UTC-8, dst: UTC-7) timezone, and the current time is 17:30. Suppose there's a rule with the followingdate_expression
:This rule will not apply because it's out of range. However, suppose we
add a timezone attribute so that it's evaluated with respect to the
America/New_York
(std: UTC-5, dst: UTC-4) time zone:Now the
date_spec
evaluation passes, and the rule applies. 17:30 in theAmerica/Los_Angeles
timezone is equivalent to 20:30 in theAmerica/New_York
timezone, and 20:30 is within thedate_spec
's range.Other timezone formats are possible. Refer to the
tzset(3)
man page.Closes T646
Closes RHBZ#2183466