[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: core: fix triggered downtimes for child hosts are missing after icinga restart ( thx Michael Lucka) #3390

git at icinga.org git at icinga.org
Sun Mar 10 15:14:30 CET 2013


Module: icinga-core
Branch: mfriedrich/core
Commit: 161d5117fa585e6cbbbef27b51a6701dfa2a8eeb
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=161d5117fa585e6cbbbef27b51a6701dfa2a8eeb

Author: Michael Friedrich <michael.friedrich at netways.de>
Date:   Sun Mar 10 14:58:23 2013 +0100

core: fix triggered downtimes for child hosts are missing after icinga restart (thx Michael Lucka) #3390

basically, the issue is 2 folded:

- the downtimes are somewhat whackily sorted in memory after being read
  from status.dat/retention.dat
- that sort order (by start time) will not allow to to check for valid
  parent downtimes when a child downtime is considered valid or invalid

the patch changes the sort order of downtimes in memory and assumes that

- parent and child downtimes have the same start time
- downtime_ids are ascending, parent before child

requires further tests, thanks Michael Lucka for the patch and analysis.

refs #3390

---

 Changelog         |    1 +
 common/downtime.c |   19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index 4db045b..7681952 100644
--- a/Changelog
+++ b/Changelog
@@ -40,6 +40,7 @@ FIXES
 * core: change ownership of debug log file before dropping privileges (Eric Stanley) #3521 - MF
 * core: fix keep_unknown_macros still exposes wrong warnings to logs #3725 - MF
 * core: fix host_check, last_check == next_check wrong in scheduling queue #2195 - MF
+* core: fix triggered downtimes for child hosts are missing after icinga restart (thx Michael Lucka) #3390 - MF
 
 * idoutils: fix many memory leaks in ido2db on dbi_result_free and others (thx Klaus Wagner) #3406 - MF
 * idoutils: fix ido2db crashes when Oracle queries fail #3324 - GB
diff --git a/common/downtime.c b/common/downtime.c
index cf6f4c0..2cfe2c7 100644
--- a/common/downtime.c
+++ b/common/downtime.c
@@ -47,6 +47,15 @@
 
 
 scheduled_downtime *scheduled_downtime_list = NULL;
+/*
+ * downtimes are not sorted by id, but starttime
+ * this leads into https://dev.icinga.org/issues/2688
+ * where child downtimes are considered invalid when
+ * looking up the parent
+ * setting this to 1 could cause unresolvable issues.
+ * the fix for child downtimes can be found in 
+ * downtime_compar()
+ */
 int		   defer_downtime_sorting = 0;
 
 #ifdef NSCORE
@@ -1067,7 +1076,17 @@ int add_downtime(int downtime_type, char *host_name, char *svc_description, time
 static int downtime_compar(const void *p1, const void *p2) {
 	scheduled_downtime *d1 = *(scheduled_downtime **)p1;
 	scheduled_downtime *d2 = *(scheduled_downtime **)p2;
+
+	/* if the valid parent is read from status/retention.dat
+	 * after the child downtime, this comparison is considered
+	 * invalid then.
+	 * the fix assumes that:
+	 * - parent and child downtimes have the same start time
+	 * - downtime_id is ascending, and parent/trigger id before child id
+	 *
 	return (d1->start_time < d2->start_time) ? -1 : (d1->start_time - d2->start_time);
+	 */
+	return (d1->start_time == d2->start_time) ? (d1->downtime_id - d2->downtime_id) : (d1->start_time - d2->start_time);
 }
 
 int sort_downtime(void) {





More information about the icinga-checkins mailing list