mirror of https://github.com/Icinga/icinga2.git
Remove Downtime objects w/o reference to ScheduledDowntime objects
fixes #11423
This commit is contained in:
parent
afc1b9bdc5
commit
8f03adf76f
|
@ -20,6 +20,7 @@
|
|||
#include "icinga/downtime.hpp"
|
||||
#include "icinga/downtime.tcpp"
|
||||
#include "icinga/host.hpp"
|
||||
#include "icinga/scheduleddowntime.hpp"
|
||||
#include "remote/configobjectutility.hpp"
|
||||
#include "base/configtype.hpp"
|
||||
#include "base/utility.hpp"
|
||||
|
@ -196,6 +197,17 @@ bool Downtime::IsExpired(void) const
|
|||
}
|
||||
}
|
||||
|
||||
bool Downtime::HasValidConfigOwner(void) const
|
||||
{
|
||||
String configOwner = GetConfigOwner();
|
||||
|
||||
if (!configOwner.IsEmpty()) {
|
||||
return (GetObject("ScheduledDowntime", configOwner) != ScheduledDowntime::Ptr());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int Downtime::GetNextDowntimeID(void)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_DowntimeMutex);
|
||||
|
@ -375,7 +387,7 @@ void Downtime::DowntimesExpireTimerHandler(void)
|
|||
|
||||
BOOST_FOREACH(const Downtime::Ptr& downtime, downtimes) {
|
||||
/* Only remove downtimes which are activated after daemon start. */
|
||||
if (downtime->IsActive() && downtime->IsExpired())
|
||||
if (downtime->IsActive() && (downtime->IsExpired() || !downtime->HasValidConfigOwner()))
|
||||
RemoveDowntime(downtime->GetName(), false, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
bool IsInEffect(void) const;
|
||||
bool IsTriggered(void) const;
|
||||
bool IsExpired(void) const;
|
||||
bool HasValidConfigOwner(void) const;
|
||||
|
||||
static int GetNextDowntimeID(void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue