86 Commits

Author SHA1 Message Date
Yonas Habteab
1d0a984d33
Merge pull request #10124 from Icinga/do-not-fail-removing-obsolete-downtimes-2.14
Don't fail to remove obsolete downtimes, remove RemoveAllDowntimes()
2024-09-17 17:17:42 +02:00
Yonas Habteab
ad7495dc0e Don't fail to remove obsolete downtimes 2024-09-17 15:06:45 +02:00
Yonas Habteab
6347c9089d Don't loose args in recursive Downtime::RemoveDowntime() call 2024-09-17 15:06:45 +02:00
Yonas Habteab
088f4e0f48 Introduce & use enum DowntimeRemovalReason 2024-09-17 15:06:45 +02:00
Alexander A. Klimov
b3c914242c l_LegacyDowntimesCache: delete removed objects not to leak memory 2024-09-17 12:33:16 +02:00
Alexander A. Klimov
58a10ad312 /v1/actions/schedule-downtime: reject request on invalid trigger_name
For this purpose lookup the specified Downtime. Also pass Downtime objects,
not just names, to Downtime::AddDowntime() not to lookup it twice.
2024-09-17 12:33:16 +02:00
Alexander A. Klimov
a3dd32e6e5 [Refactor] Downtime::GetDowntimeIDFromLegacyID(): return the Downtime itself
not just its name.
2024-09-17 12:33:16 +02:00
Alexander A. Klimov
9cf585b625 [Refactor] l_LegacyDowntimesCache: store Downtime objects, not just their names
to avoid names of vanished objects.
2024-09-17 12:33:16 +02:00
Alexander A. Klimov
58b788cd51 Downtime#Start(): trigger flexible downtimes not earlier than fixed ones
the last state change could be a long time ago. If it's longer than
the new downtime's duration, the downtime expires immediately.

trigger time + duration < now
2023-04-18 16:55:32 +02:00
Alexander A. Klimov
0ac1cd1ecb Rename Downtime::DowntimesExpireTimerHandler()
to actually reflect its purpose.
2023-04-14 14:52:05 +02:00
Alexander A. Klimov
6adf2d19e4 Remove -and notify- expired downtimes immediately, not every 60s
Don't look for expired downtimes in a timer fired every 60s,
but fire one timer per downtime once at expire time.
2023-04-14 14:52:05 +02:00
Alexander A. Klimov
21b68455ce Use Timer::Create() instead of new Timer()
git ls-files -z |xargs -0 perl -pi -e 's/\bnew Timer\b/Timer::Create/g'

ex. in Timer::Create() itself.
2023-04-04 10:35:20 +02:00
Julian Brost
0503ca1379 Initialize namespaces without using overrideFrozen
This commit adds a new initialization priority `FreezeNamespaces` that is run
last and moves all calls to `Namespace::Freeze()` there. This allows all other
initialization functions to still update namespaces without the use of the
`overrideFrozen` flag.

It also moves the initialization of `System.Platform*` and `System.Build*` to
an initialize function so that these can also be set without setting
`overrideFrozen`.

This is preparation for a following commit that will make the frozen flag in
namespaces finial, no longer allowing it to be overriden (freezing the
namespace will disable locking, so performing further updates would be unsafe).
2023-01-19 09:53:36 +01:00
Julian Brost
e518dc2436
Merge pull request #9112 from Icinga/bugfix/sync-missing-history-information
Icinga DB: ensure consistent history streams in HA setup
2022-01-07 15:14:06 +01:00
Julian Brost
3e73a262cc Sync comment and downtime removal info for Icinga DB history
When a comment or downtime is removed manually, the name of the requestor and
timestamp have to be synced to other nodes in the cluster to allow all of them
to generate a consistent Icinga DB history stream.

refs #9101
2022-01-05 10:27:13 +01:00
Julian Brost
13ea635188 Don't trigger a fixed downtime like a flexible one
When creating a fixed downtime that starts immediately while the checkable is
in a non-OK state, previously the code path for flexible downtimes was used to
trigger this downtime. This is fixed by this commit which resolves two issued:

1. Missing downtime start notification: notifications work differently for
   fixed and flexible downtimes. This resulted in missing downtime start
   notifications under the conditions described above.
2. Incorrect downtime trigger time: this code path would incorrectly assume the
   timestamp of the last checkable as the trigger time which is incorrect for
   fixed downtimes.
2021-12-14 11:02:40 +01:00
Julian Brost
c71029f2e8 Set downtime trigger time deterministically
When triggering a downtime, the time of the causing event is now passed on as
the trigger time. That time is:

* For fixed downtimes: the later one of start and entry time.
* If a check result triggers the downtime: The execution end of the check
  result.
* If another downtime triggers the downtime: The trigger time of the first
  downtime.

This is done so two nodes in a HA setup can write consistent Icinga DB downtime
history streams.

refs #9101
2021-12-08 14:15:50 +01:00
Julian Brost
596fcdc123 Downtime::DowntimesExpireTimerHandler: don't copy vector
`ConfigType::GetObjectsByType<Downtime>()` already returns a
`std::vector<Downtime::Ptr>` so there is no point in copying it into another
vector of the same type just to then iterate the copied vector instead of the
original one.
2021-12-01 13:05:23 +01:00
Noah Hilverling
7217959206 API Action 'remove-downtime': Also remove child downtimes 2021-07-23 13:53:44 +02:00
Alexander A. Klimov
1ee26ac89e Introduce Downtime#config_owner_hash
refs #8309
2021-06-29 16:38:33 +02:00
Alexander A. Klimov
d8e5e07c4f Downtime#Start(): trigger fixed downtimes immediately instead of waiting for the timer
... not to cause e.g. notifications if a problem occurs
between the downtime start time and the timer routine.
2021-06-23 19:16:15 +02:00
Alexander Aleksandrovič Klimov
ef8619f76b
Merge pull request #8601 from Icinga/feature/replace-std-boost-bind-with-lambdas-7006
Feature: Replace std/boost::bind() with lambdas
2021-03-18 17:56:13 +01:00
Yonas Habteab
43ba2da39c Replace std/boost::bind() function with lambda expression 2021-03-10 16:29:40 +01:00
Alexander A. Klimov
c3388e9af6 Use std::mutex, not boost::mutex 2021-02-03 09:54:57 +01:00
Alexander Aleksandrovič Klimov
cbd0d6ea6e
Merge pull request #8588 from Icinga/bugfix/concurrent-schedule-downtime-delete-host
Fix null pointer dereferences when deleting objects while scheduling downtimes
2021-01-19 13:51:08 +01:00
Julian Brost
88e5744d54 AddDowntime: return Downtime::Ptr instead of String containing the name
At numerous places in the code, something like this is performed:

    String name = Downtime::AddDowntime(...);
    Downtime::Ptr downtime = Downtime::GetByName(name);

However, `downtime` can be a `nullptr` after this as it is possible that
the downtime is deleted in between.

This commit changes the return type of `Downtime::AddDowntime` to return
a Downtime::Ptr instead of the full name of the downtime. `AddDowntime`
performs the very same `GetByName()` operation internally, but handles
the `nullptr` case correctly and throws an exception.
2021-01-15 16:34:48 +01:00
Julian Brost
0276c0b052 Properly handle service downtime referencing a deleted host
Only two out of three cases were handled properly by the code: host
downtimes referencing a deleted host and service downtimes referencing a
deleted service worked fine. However, if a service downtime references a
deleted host, `Host::GetByName()` returns `nullptr` which isn't
accounted for. Use `Service::GetByNamePair()` instead as this performs a
check for the host being null internally.
2021-01-08 11:12:15 +01:00
Yonas Habteab
dd02e3b6d8 API: Display a correct status code when removing a scheduled downtime 2020-12-07 13:19:41 +01:00
Alexander A. Klimov
8b0ba2275a Check !!downtime->GetCheckable() before downtime->GetCheckable()->GetName()
... not to crash while removing a downtime from a disappeared checkable.
2020-09-11 14:47:46 +02:00
Michael Friedrich
743dcad35d Improve logging for downtime/ack events (add, remove, expire)
fixes #7374
2019-08-06 13:28:58 +02:00
Michael Friedrich
d14a88235d Replace Copyright header with a short version, part I
CLion -> replace in path
2019-02-25 14:48:22 +01:00
Alexander A. Klimov
ce847324bc Downtime::AddDowntime(): place Downtimes in the same zone as the origin ScheduledDowntimes 2019-01-28 18:29:57 +01:00
Alexander A. Klimov
b09e7b287e Validate Zone::GetLocalZone() before using 2019-01-15 19:23:20 +01:00
Michael Friedrich
c4d57afa3d
Merge pull request #6821 from Icinga/bugfix/downtimes-disappear-satellite-6542
Don't delete downtimes in satellite zones
2018-12-18 16:13:36 +01:00
Alexander A. Klimov
c98d6a5254 Downtime#HasValidConfigOwner(): respect Downtime#authoritative_zone
refs #6542
2018-12-17 15:54:31 +01:00
Alexander A. Klimov
5431eae116 Add and populate Downtime#authoritative_zone
refs #6542
2018-12-17 15:54:23 +01:00
Alexander A. Klimov
39e0d787e8 Downtime#HasValidConfigOwner(): wait for ScheduledDowntimes
refs #6542
2018-12-06 15:44:57 +01:00
Michael Friedrich
dab53448bc icinga.com: Update *.{h,c}pp 2018-10-18 09:27:04 +02:00
Gunnar Beutner
17c7131177 Move new downtime constants into the Icinga namespace 2018-08-25 19:35:01 +02:00
Noah Hilverling
01fea22c77 Add child_options to ScheduledDowntime
refs #3935
2018-08-24 14:29:39 +02:00
Michael Friedrich
a8b5d8e64a
Merge pull request #6205 from Icinga/feature/api-verbose-errors
API: Unify verbose error messages
2018-04-17 16:40:11 +02:00
fbachmann
3f75ccbe75 fix bug in Downtime::IsInEffect() method that would always return false if the triggering window for a flexible downtime had passed 2018-04-10 20:16:09 +02:00
Michael Friedrich
c4a6ab0211 Add diagnostic_information as verbose error to config object handlers 2018-04-06 12:26:49 +02:00
Gunnar Beutner
94e6be1a65 Remove unused includes 2018-01-22 09:52:29 +01:00
Gunnar Beutner
9d436605f0 Fix compatibility with CMake < 3.1 2018-01-18 15:12:46 +01:00
Gunnar Beutner
21254fb610 Avoid accessing attributes for validators where not necessary 2018-01-11 08:20:16 +01:00
Gunnar Beutner
ac155d1dda Apply clang-tidy fix 'modernize-redundant-void-arg' 2018-01-04 12:24:57 +01:00
Michael Insel
158ae2188e Change copyright header for 2018 2018-01-02 12:08:55 +01:00
Jean Flach
2636e6a77a Whitespace fix
What does this change?
* Remove use of spaces for formatting
These could be found by using `grep -r -l -P '^\t+ +[^*]'
* Removal of training whitespaces
* A few lines longer than 120 chars
2017-12-20 14:53:52 +01:00
Gunnar Beutner
b63caaa756 Workaround for GCC bug 51494 2017-12-20 08:02:17 +01:00