-
Notifications
You must be signed in to change notification settings - Fork 580
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
[dev.icinga.com #13215] Newly configured already running ScheduledDowntime not put into effect #4790
Comments
Updated by tombstone on 2017-01-10 13:22:05 +00:00 I am experiencing the same issue with newly ScheduledDowntime configured with start time already in past (and end time in future) not being put into effect...very annoying.. :-/ and actually hard to work around.. |
Same here: We have some test (not in production) server which we automatically put into Downtime by a configured (via puppet) downtime with a 24x7 range:
on the first icinga2 reload, one downtime gets created for tomorrow. but it does not set a downtime for today / now (even if "now" is clearly included in the range). on the next day, there is a 2nd downtime starting tomorrow and so on, means there are always 2 downtimes per host and all services of the host. is there really no way to have a configured downtime for more than one day? I think this is somehow related to how the range is specified, but I could not find a way to do something like |
I've refactored mentioned Variant 1 (NextRunning), moving the “consider an already running segment” code into separate |
Can you turn that in a PR please? The patch is really hard to find when attached into an issue comment. Furthermore a PR allows for fine granular review and assignments. |
I just created Pull Request #6579 which fixes this issue plus the one that downtimes spanning midnight technically are two downtimes, leading to spurious DowntimeEnd/DowntimeStart notifications. |
This is fixed in #6704. |
This issue has been migrated from Redmine: https://dev.icinga.com/issues/13215
Created by edgar_fuss on 2016-11-16 14:41:29 +00:00
Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2017-01-10 13:22:05 +00:00 (in Redmine)
When you start Icinga2 while a newly configured ScheduledDowntime should be in effect, it won't.
Basically, the same goes for already existing downtimes, but the problem is normaly hidden by cacheing.
The problem is that scheduled downtimes seem to be sort-of piggy-backed on top of other downtimes. There's a timer-controlled procedure running once a minute queueing the next scheduled runtime, and it only consideres segments in the future.
I must admit I neither fully understand the underlying code nor all of it's intentions. In particular, it's not clear to me if overlapping downtimes (on the same object) are possible/intended and if yes, whether the behaviour is defined. I would expect them all to be put into effect; after reading the code, I guess that if you have three scheduled downtimes, where 1 and 3 overlap and 2 overlaps that overlapping interval, 3 is never put into effect.
Nevertheless, I can think of two ways to work around/solve the problem, which I both have implemented and somewhat tested; patches attached:
In both LegacyTimePeriod::FindNextSegment() and ScheduledDowntime::FindNextSegment(), first try to find an already-running segment before looking for segents in the future. Add a minEnd parameter to the latter routine so that ScheduledDowntime::CreateNextDowntime() can avoid an already-active downtime (or another ending earlier) to be queued over and over again.
This seems to work, but I'm not sure about the implications for other downtimes. However, ScheduledDowntime::FindNextSegment() seems to be the only caller of LegacyTimePeriod::FindNextSegment().
After loading the configuration, explicitly look for a downtime that should already be running and queue it before the timer queues a segment to come. This has the advantage of being explicit in what to do, but (as implemented by me) leads to an already-running downtime being added twice if already cached. It also needs a close-to duplication of the two FindNextSegment() routines (as FindRunningSegment()).
Various remarks on things I stumbled over while trying to fix this:
The code seems to be undecisive on "exactly now", i.e. time comparisons evaluating to equal.
In ScheduledDowntime::FindNextSegment(), the following contains dead code:
I don't get how reference can ever be used.
I don't understand what the two-pass code in LegacyTimePeriod::FindNextSegment() is supposed to do. Unless stride is non-zero, the first IsInTimeRange() should always evaluate to true (iter = begin) and I can't make up a documented case where stride is non-zero (you would need to put smething like "friday/2" in a ScheduledDowntime Object's dictionary key, I guess).
ScheduledDowntime::FindNextSegment() disregards segments which are alredy running but my impression is that LegacyTimePeriod::FindNextSegment() doesn't deliver them.
In ScheduledDowntime::FindNextSegment(), there's a debug message
where I don't understand what the " at " is supposed to mean.
In ScheduledDowntime::CreateNextDowntime(),
seems a rather involved way of writing
Attachments
The text was updated successfully, but these errors were encountered: