icinga2 icon indicating copy to clipboard operation
icinga2 copied to clipboard

Timeperiod stuck in is_inside state until double restart of icinga2

Open episodeiv opened this issue 6 years ago • 6 comments

Describe the bug

I have created a time period to send out notifications via SMS while nobody is in the office, i.e. after hours or on public holidays. That time period gets activated correctly when a holiday starts but after it should end, it's still active, judging by the SMS I'm still receiving and the value of is_inside when querying the timeperiod using the API.

Reloading or restarting icinga2 does not fix this but, oddly enough, after a second restart, the value of is_inside is correctly false and the messages stop.

To Reproduce

  1. Add the two time periods noted below
  2. Enter and then leave one day specified in the holidays time period

Expected behavior

The time period should be no longer active.

Your Environment

Include as many relevant details about the environment you experienced the problem in

  • Version used (icinga2 --version): r2.10.5-1
  • Operating System and version: Debian 9 (stretch)
  • Enabled features (icinga2 feature list): api checker command graphite ido-mysql mainlog notification perfdata
  • Icinga Web 2 version and modules (System - About): 2.6.3
  • Config validation (icinga2 daemon -C):
[2019-06-11 10:33:47 +0200] information/cli: Icinga application loader (version: r2.10.5-1)
[2019-06-11 10:33:47 +0200] information/cli: Loading configuration file(s).
[2019-06-11 10:33:47 +0200] information/ConfigItem: Committing config item(s).
[2019-06-11 10:33:47 +0200] information/ApiListener: My API identity: icinga2-master.tannenhof.intern
[2019-06-11 10:33:47 +0200] information/config: Adding b0rked http service
[2019-06-11 10:33:47 +0200] information/config: Adding b0rked http service
[2019-06-11 10:33:48 +0200] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/deploy/conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere!
[2019-06-11 10:33:48 +0200] warning/ApplyRule: Apply rule 'imap ' (in /etc/icinga2/deploy/conf.d/thof/services/mail.conf: 1:0-1:75) for type 'Service' does not match anywhere!
[2019-06-11 10:33:48 +0200] warning/ApplyRule: Apply rule 'pop3 ' (in /etc/icinga2/deploy/conf.d/thof/services/mail.conf: 13:1-13:76) for type 'Service' does not match anywhere!
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 2389 Services.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 IcingaApplication.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 309 Hosts.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 FileLogger.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 57 Dependencies.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 4 NotificationCommands.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 4447 Notifications.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 NotificationComponent.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 15 HostGroups.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 ApiListener.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 GraphiteWriter.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 PerfdataWriter.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 19 Comments.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 CheckerComponent.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 3 Zones.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 ExternalCommandListener.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 Endpoint.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 2 ApiUsers.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 5 Users.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 IdoMysqlConnection.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 237 CheckCommands.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 1 UserGroup.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 3 ServiceGroups.
[2019-06-11 10:33:48 +0200] information/ConfigItem: Instantiated 5 TimePeriods.
[2019-06-11 10:33:48 +0200] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2019-06-11 10:33:48 +0200] information/cli: Finished validating the configuration file(s).

Additional context

Timeperiod definitions

object TimePeriod "holidays" {
	import "legacy-timeperiod"

	ranges = {
		// Feste Feiertage
		"january 1"		= "00:00-24:00"		// Neujahr
		"may 1"			= "00:00-24:00"		// Tag der Arbeit
		"october 3"		= "00:00-24:00"		// Tag der Deutschen Einheit
		"november 1"	= "00:00-24:00"		// Allerheiligen
		"december 24"	= "00:00-24:00"		// Weihnachten
		"december 25"	= "00:00-24:00"		// Erster Weihnachtsfeiertag
		"december 26"	= "00:00-24:00"		// Zweiter Weihnachtsfeiertag
		"december 31"	= "00:00-24:00"		// Silvester

		// Bewegliche Feiertage
		"2019-11-01"	= "00:00-24:00"		// Allerheiligen

		"2019-04-19"	= "00:00-24:00"		// Karfreitag
		"2019-04-22"	= "00:00-24:00"		// Ostermontag
		"2019-05-30"	= "00:00-24:00"		// Christi Himmelfahrt
		"2019-06-10"	= "00:00-24:00"		// Pfingstmontag
		"2019-06-20"	= "00:00-24:00"		// Fronleichnam
	}
}

object TimePeriod "nicht-arbeitszeiten" {
	import "legacy-timeperiod"

	display_name = "Nicht-Arbeitszeiten"

	ranges = {
		"monday" 	= "00:00-07:59,16:30-23:59"
		"tuesday" 	= "00:00-07:59,16:30-23:59"
		"wednesday" = "00:00-07:59,16:30-23:59"
		"thursday" 	= "00:00-07:59,19:00-23:59"
		"friday" 	= "00:00-07:59,14:30-23:59"
		"saturday" 	= "00:00-24:00"
		"sunday" 	= "00:00-24:00"
	}

	includes = [ "holidays" ]
}

Output from icinga2 API before double restart:

<1> => get_time_period("nicht-arbeitszeiten")
{
	__name = "nicht-arbeitszeiten"
	active = true
	display_name = "Nicht-Arbeitszeiten"
	excludes = [ ]
	extensions = {
		DbObject = {
			type = "Object"
		}
	}
	ha_mode = 0.000000
	includes = [ "holidays" ]
	is_inside = true
	name = "nicht-arbeitszeiten"
	original_attributes = null
	package = "_etc"
	pause_called = false
	paused = false
	prefer_includes = true
	ranges = {
		friday = "00:00-07:59,14:30-23:59"
		monday = "00:00-07:59,16:30-23:59"
		saturday = "00:00-24:00"
		sunday = "00:00-24:00"
		thursday = "00:00-07:59,19:00-23:59"
		tuesday = "00:00-07:59,16:30-23:59"
		wednesday = "00:00-07:59,16:30-23:59"
	}
	resume_called = true
	segments = [ {
		begin = 1559944800.000000
		end = 1560319140.000000
	}, {
		begin = 1560263400.000000
		end = 1560290340.000000
	}, {
		begin = 1560349800.000000
		end = 1560376740.000000
	} ]
	source_location = {
		first_column = 1.000000
		first_line = 62.000000
		last_column = 39.000000
		last_line = 62.000000
		path = "/etc/icinga2/deploy/conf.d/thof/timeperiods.conf"
	}
	start_called = true
	state_loaded = true
	stop_called = false
	templates = [ "nicht-arbeitszeiten", "legacy-timeperiod", "legacy-timeperiod" ]
	type = "TimePeriod"
	update = {
		arguments = [ "tp", "begin", "end" ]
		deprecated = false
		name = "Internal#LegacyTimePeriod"
		side_effect_free = false
		type = "Function"
	}
	valid_begin = 1560229806.642214
	valid_end = 1560376740.000000
	vars = null
	version = 0.000000
	zone = ""
}

Output from icinga2 API after double restart (without any pending configuration changes):

{
	__name = "nicht-arbeitszeiten"
	active = true
	display_name = "Nicht-Arbeitszeiten"
	excludes = [ ]
	extensions = {
		DbObject = {
			type = "Object"
		}
	}
	ha_mode = 0.000000
	includes = [ "holidays" ]
	is_inside = false
	name = "nicht-arbeitszeiten"
	original_attributes = null
	package = "_etc"
	pause_called = false
	paused = false
	prefer_includes = true
	ranges = {
		friday = "00:00-07:59,14:30-23:59"
		monday = "00:00-07:59,16:30-23:59"
		saturday = "00:00-24:00"
		sunday = "00:00-24:00"
		thursday = "00:00-07:59,19:00-23:59"
		tuesday = "00:00-07:59,16:30-23:59"
		wednesday = "00:00-07:59,16:30-23:59"
	}
	resume_called = true
	segments = [ {
		begin = 1560204000.000000
		end = 1560232740.000000
	}, {
		begin = 1560263400.000000
		end = 1560290340.000000
	}, {
		begin = 1560290400.000000
		end = 1560319140.000000
	}, {
		begin = 1560349800.000000
		end = 1560376740.000000
	} ]
	source_location = {
		first_column = 1.000000
		first_line = 62.000000
		last_column = 39.000000
		last_line = 62.000000
		path = "/etc/icinga2/deploy/conf.d/thof/timeperiods.conf"
	}
	start_called = true
	state_loaded = true
	stop_called = false
	templates = [ "nicht-arbeitszeiten", "legacy-timeperiod", "legacy-timeperiod" ]
	type = "TimePeriod"
	update = {
		arguments = [ "tp", "begin", "end" ]
		deprecated = false
		name = "Internal#LegacyTimePeriod"
		side_effect_free = false
		type = "Function"
	}
	valid_begin = 1560117600.000000
	valid_end = 1560376740.000000
	vars = null
	version = 0.000000
	zone = ""
}

episodeiv avatar Jun 11 '19 08:06 episodeiv

@episodeiv Please could you test whether the snapshot packages are still affected. If yes, please also test the packages from here – pick your OS from the "binary" column and then "Download" the "Job artifacts".

Al2Klimov avatar Feb 27 '20 09:02 Al2Klimov

If the "Job artifacts" are already gone while you're going to test them, please let me know – I'll re-create them.

Al2Klimov avatar Feb 27 '20 13:02 Al2Klimov

@Al2Klimov I've downloaded the artifact and will test but it might be a little while before I get around to it. I'll report back though, thanks!

episodeiv avatar Feb 27 '20 14:02 episodeiv

Hi @episodeiv since you didn't respond for a long time, I'm guessing this issue has been resolved and can be closed. If this is still an issue, please just reopen it.

N-o-X avatar Sep 10 '21 14:09 N-o-X

Hi N-o-X, sorry for not getting around to it sooner. The problem still exists in 2.13.1-1 as packaged for debian systems. I now have a better setup to run tests in so if there's anything else I can provide, please let me know!

episodeiv avatar Nov 02 '21 07:11 episodeiv

Do you mean Debian's Icinga packages, our Icinga packages for Debian or the specific ones I asked you to test?

Al2Klimov avatar Dec 13 '23 14:12 Al2Klimov