mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 15:44:11 +02:00
IcingaDB: Sync affects_children
as part of runtime state updates
This commit is contained in:
parent
297b62d841
commit
6321606671
@ -122,6 +122,35 @@ bool Checkable::IsReachable(DependencyType dt, Dependency::Ptr *failedDependency
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the last check result of this Checkable affects its child dependencies.
|
||||||
|
*
|
||||||
|
* A Checkable affects its child dependencies if it runs into a non-OK state and results in any of its child
|
||||||
|
* Checkables to become unreachable. Though, that unavailable dependency may not necessarily cause the child
|
||||||
|
* Checkable to be in unreachable state as it might have some other dependencies that are still reachable, instead
|
||||||
|
* it just indicates whether the edge/connection between this and the child Checkable is broken or not.
|
||||||
|
*
|
||||||
|
* @return bool - Returns true if the Checkable affects its child dependencies, otherwise false.
|
||||||
|
*/
|
||||||
|
bool Checkable::AffectsChildren() const
|
||||||
|
{
|
||||||
|
if (!GetLastCheckResult() || !IsReachable()) {
|
||||||
|
// If there is no check result, or the Checkable is not reachable, we can't safely determine whether
|
||||||
|
// the Checkable affects its child dependencies.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& dep : GetReverseDependencies()) {
|
||||||
|
if (!dep->IsAvailable(DependencyState)) {
|
||||||
|
// If one of the child dependency is not available, then it's definitely due to the
|
||||||
|
// current Checkable state, so we don't need to verify the remaining ones.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::set<Checkable::Ptr> Checkable::GetParents() const
|
std::set<Checkable::Ptr> Checkable::GetParents() const
|
||||||
{
|
{
|
||||||
std::set<Checkable::Ptr> parents;
|
std::set<Checkable::Ptr> parents;
|
||||||
|
@ -82,6 +82,7 @@ public:
|
|||||||
void AddGroup(const String& name);
|
void AddGroup(const String& name);
|
||||||
|
|
||||||
bool IsReachable(DependencyType dt = DependencyState, intrusive_ptr<Dependency> *failedDependency = nullptr, int rstack = 0) const;
|
bool IsReachable(DependencyType dt = DependencyState, intrusive_ptr<Dependency> *failedDependency = nullptr, int rstack = 0) const;
|
||||||
|
bool AffectsChildren() const;
|
||||||
|
|
||||||
AcknowledgementType GetAcknowledgement();
|
AcknowledgementType GetAcknowledgement();
|
||||||
|
|
||||||
|
@ -2828,6 +2828,7 @@ Dictionary::Ptr IcingaDB::SerializeState(const Checkable::Ptr& checkable)
|
|||||||
attrs->Set("check_attempt", checkable->GetCheckAttempt());
|
attrs->Set("check_attempt", checkable->GetCheckAttempt());
|
||||||
|
|
||||||
attrs->Set("is_active", checkable->IsActive());
|
attrs->Set("is_active", checkable->IsActive());
|
||||||
|
attrs->Set("affects_children", checkable->AffectsChildren());
|
||||||
|
|
||||||
CheckResult::Ptr cr = checkable->GetLastCheckResult();
|
CheckResult::Ptr cr = checkable->GetLastCheckResult();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user