1774 Commits

Author SHA1 Message Date
Julian Brost
5a6b2044b1
Merge pull request #10290 from Icinga/icingadb-dependencies-sync
Sync dependencies to Redis
2025-04-04 15:13:05 +02:00
Julian Brost
31a224c509 Checkable::GetSeverity(): always take reachability into account
So far, Service::GetSeverity() only considered the state of its own host, i.e.
the implicit service to its own host dependency, and treated it similar to
acknowledgements and downtimes. In contrast, Host::GetSeverity() considered
reachability and treated it like a state, i.e. for the severity calculation,
the host was either up, down, or unreachable.

This commit changes the following things:
1. Make the service severity also consider explicitly configured dependencies
   by using IsReachable().
2. Prefer acknowledgements and downtimes over unreachability in the severity
   calculation so that if an already acknowledged or in-downtime services (i.e.
   already handled service) becomes unreachable, it shouln't become more
   severe.
3. To unify host and service severities a bit, hosts now use the same logic
   that treats reachability more like acknowledgements/downtimes instead of
   like a state (changing the other way around would the state from the check
   plugin would not affect the severity for unrachable services anymore).
2025-03-31 15:23:51 +02:00
Julian Brost
1e05a166f1 Host::GetSeverity(): remove empty line at end of method 2025-03-31 15:23:51 +02:00
Julian Brost
d8271c6568 Host::GetSeverity(): remove explicit unlocking
No change in functionality. The ObjectLock destructor will implicitly release
the locks when returning from the function.
2025-03-31 15:23:51 +02:00
Julian Brost
2ebee010f0 Host::GetHost(): return early to remove a nesting level
No change in functionality. The first two branches actually set the final
return value for the method, so they can just return directly, removing the
need to have the rest of the function inside an else block.
2025-03-31 15:23:51 +02:00
Julian Brost
6443f8997f Host::GetSeverity(): add braces to if statements
No change in functionality, just makes the code a bit nicer.
2025-03-31 15:23:51 +02:00
Julian Brost
c899d52e2f Service::GetSeverity(): remove explicit unlocking
No change in functionality. The ObjectLock destructor will implicitly release
the locks when returning from the function.
2025-03-31 15:23:50 +02:00
Julian Brost
01acfb47a9 Service::GetHost(): return early to remove a nesting level
No change in functionality. The first two branches actually set the final
return value for the method, so they can just return directly, removing the
need to have the rest of the function inside an else block.
2025-03-31 15:23:50 +02:00
Julian Brost
5ca6047b35 Service::GetSeverity(): replace switch with if
No change in functionality, just making the code a bit more compact.
2025-03-31 15:23:50 +02:00
Julian Brost
a1865e1b43 Service::GetSeverity(): simplify nested if, add braces
No change in functionality, just making the code a bit nicer and more compact.
2025-03-31 15:23:50 +02:00
Julian Brost
061338156c
Merge pull request #10345 from Icinga/remove-child-downtimes
ApiActions: Remove child downtimes recursively
2025-03-21 16:37:43 +01:00
Julian Brost
065118bc22 Make DependencyGroup::State an enum
The previous struct used two bools to represent three useful states. Make this
more explicit by having these three states as an enum.
2025-03-19 16:28:00 +01:00
Yonas Habteab
864e2aaae0 Drop superfluous mutex lock & don't manually unpack std::tuple 2025-03-19 16:28:00 +01:00
Julian Brost
693d094ebc DependencyGroup: don't change the keys of m_Members after construction
This prevents the use of DependencyGroup for storing the dependencies during
the early registration (m_DependencyGroupsPushedToRegistry = false),
m_PendingDependencies is introduced as a replacement to store the dependencies
at that time.
2025-03-19 16:28:00 +01:00
Yonas Habteab
21cd5e00fa Dependency: Don't allow to update {period,states,ignore_soft_states} at runtime 2025-03-19 16:28:00 +01:00
Yonas Habteab
a9bb11b16d (Un)register dependencies from parent prior to child Checkable 2025-03-19 16:28:00 +01:00
Yonas Habteab
7fbb8f7452 Evaluate dependency group state only for a specific child
Previously the dependency state was evaluated by picking the first
dependency object from the batched members. However, since the
dependency `disable_{checks,notifications` attributes aren't taken into
account when batching the members, the evaluated state may yield a wrong
result for some Checkables due to some random dependency from other
Checkable of that group that has the `disable_{checks,notifications`
attrs set. This commit forces the callers to always provide the child
Checkable the state is evaluated for and picks only the dependency
objects of that child Checkable.
2025-03-19 16:28:00 +01:00
Julian Brost
ce1ed8556c Simplify DependencyGroup::GetState() implementation
The new implementation just counts reachable and available parents and
determines the overall result by comparing numbers, see inline comments for
more information.

This also fixes an issue in the previous implementation: if it didn't return
early from the loop, it would just return the state of the last parent
considered which may not actually represent the group state accurately.
2025-03-19 16:28:00 +01:00
Yonas Habteab
915ea6427e Use GetParents() in FireSppressedNotifications()
It's way efficient than accessing them through the dependency objects,
plus we won't have any duplicates.
2025-03-19 16:28:00 +01:00
Yonas Habteab
8640a3f84e Checkable: Extract parents directly from dependency groups 2025-03-19 16:28:00 +01:00
Yonas Habteab
806fff950c Checkable: Emit boost signals when changing dependency groups at runtime 2025-03-19 16:28:00 +01:00
Yonas Habteab
67a4889945 Checkable: Delay dependency group global registration on startup 2025-03-19 16:28:00 +01:00
Julian Brost
26f46fe021 Simplify dependency group registration
Co-Authored-By: Yonas Habteab <yonas.habteab@icinga.com>
2025-03-19 16:28:00 +01:00
Yonas Habteab
f502993eb4 IcingaDB: Sync dependencies states to Redis 2025-03-19 16:28:00 +01:00
Yonas Habteab
66cc6a4d8a ClusterEvents: Sync & process notification notified_problem_users 2025-03-14 14:13:55 +01:00
Yonas Habteab
3d761c0296 ApiActions: Remove child downtimes recursively
Services downtimes scheduled via the `all_services` flag get already
removed automatically when removing their parent downtimes (introduced
with #8913). Now, this commit makes it possible to perform the same actions
for all child downtimes, i.e. not only for those of service objects, but
for all child objects represented in the dependency tree.
2025-03-13 12:13:45 +01:00
Yonas Habteab
d094581b4b Checkable: Use redundancy groups state in IsReachable 2025-03-12 16:32:01 +01:00
Yonas Habteab
27f11a0955 Checkable: Introduce HasAnyDependencies() method 2025-03-12 16:32:01 +01:00
Yonas Habteab
ff0dabe287 Checkable: Store dependencies grouped by their redundancy group 2025-03-12 16:31:59 +01:00
Yonas Habteab
1820955993 Add DependencyGroup::GetState() helper method 2025-03-12 16:31:14 +01:00
Yonas Habteab
d7c9e6687e Introduce DependencyGroup helper class 2025-03-12 16:31:12 +01:00
Yonas Habteab
93d9fad565 Checkable: Drop unused failedDependency argument from IsReachable() 2025-03-12 16:19:22 +01:00
Julian Brost
67664ad7b7 Checkable::GetAllChildrenInternal: remove redundant emplace call
`checkable` is already added to the set by the insert call above, so calling
emplace for the same checkable doesn't do anything useful and can be removed.
2025-03-12 16:19:22 +01:00
Yonas Habteab
c465f45200 Rewrite Checkable::GetAllChildrenInternal() method
The previous wasn't per-se wrong, but it was way too inefficient. With
this commit each and every Checkable is going to be visited only once,
and we won't traverse the same Checkable's children multiple times
somewhere in the dependency chain.
2025-03-12 16:19:22 +01:00
Yonas Habteab
e0ce0ccff6 Activate Dependency objects before their parent objects 2025-03-12 16:19:22 +01:00
Yonas Habteab
772420a438 Checkable: Don't always trigger reachablity changed signal
But only when the current check result being processed affects the child
Checkables in any way.
2025-03-12 16:19:22 +01:00
Yonas Habteab
c64ae1af0f Dependency: Don't allow to change redundancy_group at runtime
Otherwise, it would require too much code changes to properly handle
redundancy group runtime modification in Icinga DB for no real benefit.
2025-03-12 16:19:22 +01:00
Yonas Habteab
6321606671 IcingaDB: Sync affects_children as part of runtime state updates 2025-03-12 16:19:22 +01:00
Yonas Habteab
d6b289e1cd Checkable: Introduce GetAllChildrenCount() method
The previous limit (32) doesn't seem to make sense, and appears to be some random number.
So, this limit is set to 256 to match the limit in IsReachable().
2025-03-12 16:19:22 +01:00
Julian Brost
8e7e687b96 Unify depependency cycle check code.
This commit removes a distinction in how dependency objects are checked for
cycles in the resulting graph depending on whether they are part of the
initially loaded configuration during process startup or as part of a runtime
update.

The DependencyCycleChecker helper class is extended with a mechanism that
allows additional dependencies to be considered during the cycle search. This
allows using it to check for cycles before actually registering the
dependencies with the checkables.

The aforementioned case-distinction for initial/runtime-update config is
removed by making use of the newly added BeforeOnAllConfigLoaded signal to
perform the cycle check at once for each batch of dependencies inside
ConfigItem::CommitNewItems() for both cases now. During the initial config
loading, there can be multiple batches of dependencies as objects from apply
rules are created separately, so parts of the dependency graph might be visited
multiple times now, however that is limited to a minimum as only parts of the
graph that are reachable from the newly added dependencies are searched.
2025-03-12 11:53:30 +01:00
Julian Brost
c1b270f39f Rework dependency cycle check
This commit groups a bunch of structs and static functions inside
dependency.cpp into a new DependencyCycleChecker helper class. In the process,
the implementation was changed a bit, the behavior should be unchanged except
for a more user-friendly error message in the exception.
2025-03-12 11:53:30 +01:00
Julian Brost
880632b93a
Merge pull request #9861 from ymartin-ovh/issue-9752
icinga2: address comment loading where host reference is not found
2025-01-07 14:12:03 +01:00
Alexander A. Klimov
35a705752f Don't set Notification#no_more_notifications on custom notifications 2024-11-15 13:03:22 +01:00
Alexander Aleksandrovič Klimov
5f487aff1b
Merge pull request #10201 from Icinga/Validation-failed
Remove redundant "Validation failed" prefix from ValidationError exceptions
2024-10-31 12:30:39 +01:00
Alexander Aleksandrovič Klimov
4ca68e444e
Merge pull request #10204 from Icinga/an-HA
doc/: fix "a HA" -> "an HA"
2024-10-24 11:30:24 +02:00
Alexander Aleksandrovič Klimov
fb8badfd2e
Merge pull request #10187 from Icinga/state-before-suppression
Fix lost recovery notifications after recovery outside of notification time period
2024-10-24 10:07:59 +02:00
Alexander A. Klimov
095e5982f4 doc/: fix "a HA" -> "an HA" 2024-10-24 09:44:36 +02:00
Alexander A. Klimov
7a4ba59961 Remove redundant "Validation failed" prefix from ValidationError exceptions
ValidationError#ValidationError() already prefixes #m_What,
which #what() returns, with "Validation failed for object".
2024-10-23 13:06:12 +02:00
Julian Brost
7d0a43f926 Use Checkable::GetStateBeforeSuppression() only where relevant
This fixes an issue where recovery notifications get lost if they happen
outside of a notification time period.

Not all calls to `Checkable::NotificationReasonApplies()` need
`GetStateBeforeSuppression()` to be checked. In fact, for one caller,
`FireSuppressedNotifications()` in
`lib/notification/notificationcomponent.cpp`, the state before suppression may
not even be initialized properly, so that the default value of OK is used which
can lead to incorrect return values. Note the difference between suppressions
happening on the level of the `Checkable` object level and the `Notification`
object level. Only the first sets the state before suppression in the
`Checkable` object, but so far, also the latter used that value incorrectly.

This commit moves the check of `GetStateBeforeSuppression()` from
`Checkable::NotificationReasonApplies()` to the one place where it's actually
relevant: `Checkable::FireSuppressedNotifications()`. This made the existing
call to `NotificationReasonApplies()` unneccessary as it would always return
true: the `type` argument is computed based on the current check result, so
there's no need to check it against the current check result.
2024-10-11 13:21:10 +02:00
Alexander A. Klimov
2bbeaec916 Fix build on Mac with -DICINGA2_UNITY_BUILD=OFF -DICINGA2_WITH_LIVESTATUS=ON
error: no matching function for call to 'intrusive_ptr_release'
...
candidate function not viable: cannot convert argument of incomplete type 'icinga::Notification *' to 'Object *' for 1st argument
void intrusive_ptr_release(Object *object);
2024-09-27 12:41:11 +02:00