Only create downtimes from non-paused ScheduledDowntime objects in HA enabled cluster zones

This commit is contained in:
Michael Friedrich 2018-12-04 15:20:37 +01:00
parent 1d6cec5a99
commit 78e470996d
1 changed files with 11 additions and 3 deletions

View File

@ -95,13 +95,14 @@ void ScheduledDowntime::Start(bool runtimeCreated)
l_Timer->Start();
});
Utility::QueueAsyncCallback(std::bind(&ScheduledDowntime::CreateNextDowntime, this));
if (!IsPaused())
Utility::QueueAsyncCallback(std::bind(&ScheduledDowntime::CreateNextDowntime, this));
}
void ScheduledDowntime::TimerProc()
{
for (const ScheduledDowntime::Ptr& sd : ConfigType::GetObjectsByType<ScheduledDowntime>()) {
if (sd->IsActive())
if (sd->IsActive() && !sd->IsPaused())
sd->CreateNextDowntime();
}
}
@ -167,6 +168,13 @@ std::pair<double, double> ScheduledDowntime::FindNextSegment()
void ScheduledDowntime::CreateNextDowntime()
{
/* HA enabled zones. */
if (IsActive() && IsPaused()) {
Log(LogNotice, "Checkable")
<< "Skipping downtime creation for HA-paused Scheduled Downtime object '" << GetName() << "'";
return;
}
for (const Downtime::Ptr& downtime : GetCheckable()->GetDowntimes()) {
if (downtime->GetScheduledBy() != GetName() ||
downtime->GetStartTime() < Utility::GetTime())
@ -261,4 +269,4 @@ void ScheduledDowntime::ValidateChildOptions(const Lazy<Value>& lvalue, const Va
} catch (const std::exception&) {
BOOST_THROW_EXCEPTION(ValidationError(this, { "child_options" }, "Invalid child_options specified"));
}
}
}