Prevent duplicate donwtimes when combining child_options and all_services

This commit is contained in:
Julian Brost 2021-09-03 12:05:34 +02:00
parent e556d3c489
commit bb0dcdf0b4
1 changed files with 15 additions and 5 deletions

View File

@ -434,7 +434,21 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
ArrayData childDowntimes;
for (const Checkable::Ptr& child : checkable->GetAllChildren()) {
std::set<Checkable::Ptr> allChildren = checkable->GetAllChildren();
for (const Checkable::Ptr& child : allChildren) {
Host::Ptr childHost;
Service::Ptr childService;
tie(childHost, childService) = GetHostService(child);
if (allServices && childService &&
allChildren.find(static_pointer_cast<Checkable>(childHost)) != allChildren.end()) {
/* When scheduling downtimes for all service and all children, the current child is a service, and its
* host is also a child, skip it here. The downtime for this service will be scheduled below together
* with the downtimes of all services for that host. Scheduling it below ensures that the relation
* from the child service downtime to the child host downtime is set properly. */
continue;
}
Log(LogNotice, "ApiActions")
<< "Scheduling downtime for child object " << child->GetName();
@ -451,10 +465,6 @@ Dictionary::Ptr ApiActions::ScheduleDowntime(const ConfigObject::Ptr& object,
});
/* For a host, also schedule all service downtimes if requested. */
Host::Ptr childHost;
Service::Ptr childService;
tie(childHost, childService) = GetHostService(child);
if (allServices && !childService) {
ArrayData childServiceDowntimes;