Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync dependencies to Redis #10290

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9e0f750
IcingaDB: Start keeping track of Host/Service to Dependency relationship
oxzi Oct 21, 2024
5fc78da
Checkable: Introduce `GetAllChildrenCount()` method
yhabteab Dec 2, 2024
66c6291
IcingaDB: Add `affected_children` to `Host/Service` Redis updates
yhabteab Dec 2, 2024
0c48e58
IcingaDB: Sync `affects_children` as part of runtime state updates
yhabteab Dec 2, 2024
2c3bf98
Dependency: Don't allow to change `redundancy_group` at runtime
yhabteab Dec 5, 2024
e2e4289
Introduce `DependencyGroup` helper class
yhabteab Dec 5, 2024
19c81da
DependencyGroup: Add a global registry & deduplication logic
yhabteab Dec 12, 2024
25c0dfe
Checkable: Drop unused `failedDependency` argument from `IsReachable()`
yhabteab Dec 12, 2024
c932e26
Add `DependencyGroup::GetState()` helper method
yhabteab Dec 5, 2024
671c27e
Checkable: Store dependencies grouped by their redundancy group
yhabteab Dec 4, 2024
3f47547
IcingaDB: Dump checkables dependencies config to redis correctly
yhabteab Dec 4, 2024
6bbd530
IcingaDB: Sync dependencies states to Redis
yhabteab Dec 4, 2024
5996533
IcingaDB: Sync dependencies initial states on config dump
yhabteab Dec 5, 2024
b9d7daa
IcingaDB: Handle runtime removed dependencies correctly
yhabteab Dec 9, 2024
8d17d75
Checkable: Use redundancy groups state in `IsReachable`
yhabteab Dec 16, 2024
f323b42
tests: Add unittests for the redundancy groups registry
yhabteab Dec 16, 2024
8cb5568
IcingaDB: Bump expected redis version to `6`
yhabteab Dec 16, 2024
d8d504f
Activate `Dependency` objects before their parent objects
yhabteab Jan 10, 2025
f6c61cc
tests: Add the new unittests to the `CMakefile.txt`
yhabteab Jan 13, 2025
1c11a2b
IcingaDB: Send reachablity state updates for all children recursively
yhabteab Jan 15, 2025
d155543
Simplify dependency (un)registration path
yhabteab Jan 28, 2025
47a1130
Fix & adjust dependencies unittests
yhabteab Jan 28, 2025
fe559ef
Add basic unittests for bulk group registration
yhabteab Jan 28, 2025
e0b4e52
IcingaDB: Fix dependency runtime deletion & creation
yhabteab Jan 29, 2025
4149f5a
Fix wrong indention
yhabteab Jan 29, 2025
223bd04
Fix wrong unittest assertions
yhabteab Jan 29, 2025
e083b31
Rewrite `Checkable::GetAllChildrenInternal()` method
yhabteab Jan 31, 2025
dc5da1b
Fix unittests
yhabteab Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/icinga/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set(icinga_SOURCES
comment.cpp comment.hpp comment-ti.hpp
compatutility.cpp compatutility.hpp
customvarobject.cpp customvarobject.hpp customvarobject-ti.hpp
dependency.cpp dependency.hpp dependency-ti.hpp dependency-apply.cpp
dependency.cpp dependency-group.cpp dependency.hpp dependency-ti.hpp dependency-apply.cpp
downtime.cpp downtime.hpp downtime-ti.hpp
envresolver.cpp envresolver.hpp
eventcommand.cpp eventcommand.hpp eventcommand-ti.hpp
Expand Down
347 changes: 280 additions & 67 deletions lib/icinga/checkable-dependency.cpp

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/icinga/checkable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ void Checkable::OnAllConfigLoaded()

void Checkable::Start(bool runtimeCreated)
{
PushDependencyGroupsToRegistry();

double now = Utility::GetTime();

{
Expand Down
26 changes: 21 additions & 5 deletions lib/icinga/checkable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum FlappingStateFilter
class CheckCommand;
class EventCommand;
class Dependency;
class DependencyGroup;

/**
* An Icinga service.
Expand All @@ -77,10 +78,12 @@ class Checkable : public ObjectImpl<Checkable>
std::set<Checkable::Ptr> GetParents() const;
std::set<Checkable::Ptr> GetChildren() const;
std::set<Checkable::Ptr> GetAllChildren() const;
size_t GetAllChildrenCount() const;

void AddGroup(const String& name);

bool IsReachable(DependencyType dt = DependencyState, intrusive_ptr<Dependency> *failedDependency = nullptr, int rstack = 0) const;
bool IsReachable(DependencyType dt = DependencyState, int rstack = 0) const;
bool AffectsChildren() const;

AcknowledgementType GetAcknowledgement();

Expand Down Expand Up @@ -182,9 +185,12 @@ class Checkable : public ObjectImpl<Checkable>
bool IsFlapping() const;

/* Dependencies */
void AddDependency(const intrusive_ptr<Dependency>& dep);
void RemoveDependency(const intrusive_ptr<Dependency>& dep);
void PushDependencyGroupsToRegistry();
std::vector<intrusive_ptr<DependencyGroup>> GetDependencyGroups() const;
intrusive_ptr<DependencyGroup> AddDependency(const intrusive_ptr<Dependency>& dependency);
intrusive_ptr<DependencyGroup> RemoveDependency(const intrusive_ptr<Dependency>& dependency);
std::vector<intrusive_ptr<Dependency> > GetDependencies() const;
bool HasAnyDependencies() const;

void AddReverseDependency(const intrusive_ptr<Dependency>& dep);
void RemoveReverseDependency(const intrusive_ptr<Dependency>& dep);
Expand Down Expand Up @@ -242,12 +248,22 @@ class Checkable : public ObjectImpl<Checkable>
std::set<Notification::Ptr> m_Notifications;
mutable std::mutex m_NotificationMutex;

struct HashDependencyGroup
{
size_t operator()(const intrusive_ptr<DependencyGroup>& dependencyGroup) const;
};

struct EqualDependencyGroups
{
bool operator()(const intrusive_ptr<DependencyGroup>& lhs, const intrusive_ptr<DependencyGroup>& rhs) const;
};

/* Dependencies */
mutable std::mutex m_DependencyMutex;
std::set<intrusive_ptr<Dependency> > m_Dependencies;
std::unordered_set<intrusive_ptr<DependencyGroup>, HashDependencyGroup, EqualDependencyGroups> m_DependencyGroups;
std::set<intrusive_ptr<Dependency> > m_ReverseDependencies;

void GetAllChildrenInternal(std::set<Checkable::Ptr>& children, int level = 0) const;
void GetAllChildrenInternal(std::set<Checkable::Ptr>& seenChildren, int level = 0) const;

/* Flapping */
static const std::map<String, int> m_FlappingStateFilterMap;
Expand Down
Loading
Loading