12887 Commits

Author SHA1 Message Date
Alexander Aleksandrovič Klimov
0ee074ab24 GHA: add Fedora 35 2022-01-04 18:57:12 +01:00
Alexander Aleksandrovič Klimov
68133b87d2 GHA: drop Fedora 33
It's EOL.
2022-01-04 18:57:12 +01:00
Alexander A. Klimov
e9e555468d Handle "type" key in dicts being part of object state attrs
i.e. the confusion of the state file deserializator with e.g. `"type":32` on startup.
That would unexpectedly restore (the now ignored) null (not `{"type":32}`) as there's no type "32".

refs #8186
2022-01-04 17:17:20 +01:00
Julian Brost
a07a749e92 Document which other downtimes are deleted by /v1/actions/remove-downtime 2022-01-03 18:47:32 +01:00
Julian Brost
754943c15f Prevent duplicate donwtimes when combining child_options and all_services 2022-01-03 18:47:32 +01:00
Julian Brost
2de9904676 Fix scheduling of downtimes for all services on child hosts
The loop iterated over the services of the wrong host resulting in duplicate
downtimes scheduled for services of the parent host instead of downtimes for
services of the child host.
2022-01-03 18:47:32 +01:00
Julian Brost
8937daac74 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.
2022-01-03 18:45:16 +01:00
Julian Brost
91e120cd28 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
2022-01-03 18:42:50 +01:00
Julian Brost
1275a5a245 third-party: update GetGitRevisionDescription CMake module
The new version includes functionality to prevent using version information
from parent directories of the source root directory.

wget -O third-party/cmake/GetGitRevisionDescription.cmake https://raw.githubusercontent.com/rpavlik/cmake-modules/main/GetGitRevisionDescription.cmake
wget -O third-party/cmake/GetGitRevisionDescription.cmake.in https://raw.githubusercontent.com/rpavlik/cmake-modules/main/GetGitRevisionDescription.cmake.in
2022-01-03 18:37:02 +01:00
Alexander Aleksandrovič Klimov
93c1e313bc
Merge pull request #9094 from Icinga/bugfix/non-unity-build-2.13
Add missing include to fix non-unity builds
2021-12-20 10:22:31 +01:00
Julian Brost
1d49e5c405 Make MySQL schema version in full schema file and upgrade files consistent
In the 2.12.6 release, the full schema file sets the version to 1.14.3, whereas
the latest available upgrade file 2.11.0.sql sets it to 1.15.0. Therefore, ship
a new upgrade file 2.12.7.sql for all users who imported their schema with
version 2.11.0 or later and never performed an upgrade since then. Their
databases incorrectly state schema version 1.14.3 and is bumped to the correct
version 1.15.0 by the upgrade.

In the 2.13.2 release, the full schema file sets the version to 1.15.0, whereas
the latest available upgrade file 2.13.0.sql sets it to 1.15.1. Therefore,
rename the incorrectly named upgrade file 2.13.1.sql (it was not shipped in
this or any other release so far) to 2.13.3.sql for users who imported their
schema with version 2.13.0 or later and never performed an upgrade since then.
Their databases incorrectly state schema version 1.15.0 and are bumped to the
correct version 1.15.1 by the upgrade. Additionally, the version number in the
full schema is also bumped to the correct version 1.15.1.
2021-12-16 16:01:04 +01:00
Alexander A. Klimov
eb71fb7529 Avoid "type" key in dicts being part of object state attrs
not to confuse the state file deserializator with e.g. `"type":32` on startup.
That would unexpectedly restore null (not `{"type":32}`) as there's no type "32".

refs #8186
2021-12-13 17:56:12 +01:00
Julian Brost
a107792d06 Add missing include to fix non-unity builds
This commit fixes the following build error:

    [ 55%] Building CXX object lib/icinga/CMakeFiles/icinga.dir/usergroup.cpp.o
    lib/icinga/usergroup.cpp:79:24: error: incomplete type ‘icinga::Notification’ used in nested name specifier
       79 | std::set<Notification::Ptr> UserGroup::GetNotifications() const
          |                        ^~~
2021-11-19 13:49:10 +01:00
Noah Hilverling
31c4ba31b8
Merge pull request #9087 from Icinga/feature/2.13.2-changelog-and-version
Add 2.13.2 CHANGELOG and bump version
v2.13.2
2021-11-12 18:34:48 +01:00
Noah Hilverling
dbe546570c
Merge pull request #9089 from Icinga/bugfix/icingadb-runtime-updates-delete-relationships-2.13
Icinga DB: Make sure object relationships are handled correctly during runtime updates
2021-11-12 18:34:26 +01:00
Noah Hilverling
4a9e77f711 Add 2.13.2 CHANGELOG and bump version 2021-11-12 18:14:58 +01:00
Noah Hilverling
950b78d8cd
Merge pull request #9088 from Icinga/bugfix/icingadb-log-queries-debug-level-2.13
Icinga DB: only log queries at debug level
2021-11-12 17:57:48 +01:00
Noah Hilverling
4fd1b153fa IcingaDB::AddObjectDataToRuntimeUpdates(): Copy data before modifying 2021-11-12 17:55:47 +01:00
Noah Hilverling
6ddac83d81 Dictionary: Make sure underlaying map is ordered 2021-11-12 17:55:47 +01:00
Noah Hilverling
2d2b165a79 Icinga DB: Make sure object relationships are handled correctly 2021-11-12 17:55:47 +01:00
Julian Brost
3254ebd0be Icinga DB: only log queries at debug level 2021-11-12 16:37:34 +01:00
Noah Hilverling
73d98cc2ff
Merge pull request #9083 from Icinga/bugfix/icingadb-improve-object-identifier-function-2.13
IcingaDB: Remove GetObjectIdentifiersWithoutEnv()
2021-11-12 13:04:07 +01:00
Noah Hilverling
65a39bfd27
Merge pull request #9085 from Icinga/bugfix/icingadb-prefix-command_id-2.13
IcingaDB: Prefix command_id with command type
2021-11-12 13:03:57 +01:00
Noah Hilverling
b55e924e8b IcingaDB: Prefix command_id with command type 2021-11-12 10:19:18 +01:00
Noah Hilverling
d164d66808 IcingaDB: Remove GetObjectIdentifiersWithoutEnv()
Having the command type be a part of the command ID isn't needed anywhere. Removing this simplifies the way we generate IDs in general, because we don't need Prepend() anymore.

The command type was only needed to prevent ID collisions within the command_envvar and command_argument tables. Those tables have since been separated into {check,event,notification}command_envvar and {check,event,notification}command_argument tables.
2021-11-12 10:18:33 +01:00
Noah Hilverling
3fdcfaf0ca
Merge pull request #9082 from Icinga/feature/icingadb-environment-2.13
Icinga DB: decouple environment from Icinga 2 Environment constant
2021-11-12 09:56:18 +01:00
Julian Brost
9a5ba28e0c Icinga DB: increase Redis schema version
PR #9036 introduces some incompatible changes to the Redis schema, most
importantly where Icinga DB has to read the environment from: now it has to use
a new top-level key of the icinga:stats message instead of a value in the
IcingaApplication part of that message.
2021-11-11 16:58:16 +01:00
Julian Brost
d3ec8a9ba8 IcingaDB: export environment_id via API
Primarily required for Icinga DB integration tests at the moment, but could
also be helpful in other situations.
2021-11-11 16:58:16 +01:00
Julian Brost
b98b951f85 IcingaDB: write new environment to icinga:stats stream 2021-11-11 16:58:16 +01:00
Julian Brost
42fc3cdcfc IcingaDB: introduce a new environment ID derived from the CA public key
In order to avoid changes to the environment ID, it is now no longer derived
from the Environment constant but instead from the public key of the CA
certificate. This ensures that it is different between clusters by default, so
no additional changes have to be done to allow two clusters to use Icinga DB to
write into the same database.

To prevent the ID from changing when the CA certificate is replaced, it is also
persisted into the file /var/lib/icinga2/icingadb.env, so if that file exists,
it takes precedence over the CA certificate.
2021-11-11 16:58:16 +01:00
Julian Brost
1dcba7d127 tlsutility: move hex encoding into a separate function BinaryToHex 2021-11-11 16:58:16 +01:00
Noah Hilverling
e1dbfa1011
Merge pull request #9076 from Icinga/feature/icingadb-history-deterministic-ids-2.13
Icinga DB: make icinga:history:stream:*#event_id deterministic
2021-11-11 16:57:10 +01:00
Noah Hilverling
20828dc6e4
Merge pull request #9084 from Icinga/add-downtime-duration-and-service-state-host-id-streams-2.13
Icinga DB: Add `downtime.duration` & `service_state.host_id` to Redis
2021-11-11 15:27:52 +01:00
Noah Hilverling
b536caa4dc
Merge pull request #9081 from Icinga/feature/sync-checkables-states-first-2.13
Icinga DB: sync checkables along with their states first
2021-11-11 15:27:42 +01:00
Noah Hilverling
c05866686f
Merge pull request #9079 from Icinga/bugfix/idb-dump-buf-lost-2.13
Icinga DB init. dump: flush both buffered states and state checksums
2021-11-11 15:27:35 +01:00
Noah Hilverling
bf46fc447f
Merge pull request #9080 from Icinga/feature/scheduled_by-2.13
Icinga DB: introduce icinga:history:stream:downtime#scheduled_by
2021-11-11 15:27:28 +01:00
Noah Hilverling
88a16ff752
Merge pull request #9078 from Icinga/bugfix/icingadb-zone-parent-2.13
IcingaDB: actually write parent to parent_id of zones
2021-11-11 14:18:40 +01:00
Noah Hilverling
46aa8c9e65
Merge pull request #9077 from Icinga/bugfix/icingadb-program-start-milliseconds-2.13
Icinga DB: set value in milliseconds for program_start in stats/heartbeat
2021-11-11 12:24:11 +01:00
Yonas Habteab
ca2f54352f Icinga DB: Add service_state.host_id to Redis 2021-11-11 10:34:24 +01:00
Yonas Habteab
f470c52819 Icinga DB: Add downtime.duration & scheduled_duration to Redis 2021-11-11 10:34:24 +01:00
Eric Lippmann
8c18708819 Icinga DB: Sync groups earlier
Host and service groups are structural information that are used
for Web filters and should therefore be synchronized as soon as
possible.
2021-11-10 17:34:21 +01:00
Alexander A. Klimov
315a08ed9f Icinga DB: sync checkables along with their states first
`WorkQueue#ParallelFor(x, false, y)` will enqueue x's items in FIFO order,
so x has to start with host and service.
2021-11-10 17:34:14 +01:00
Julian Brost
4658fbd0b4 Icinga DB: set value in milliseconds for program_start in stats/heartbeat 2021-11-10 17:33:26 +01:00
Julian Brost
d774ae1186 IcingaDB: actually write parent to parent_id of zones
This fixes that the code used the wrong variable. Previously, it was written to
Redis that each zone is its own parent (if it has a parent at all).
2021-11-10 17:29:53 +01:00
Alexander A. Klimov
9fa92aff97 Icinga DB: raise icinga:schema 1 -> 2 2021-11-10 17:24:55 +01:00
Alexander A. Klimov
1b06444b8d Icinga DB: make icinga:history:stream:*#event_id deterministic
... i.e. UUID -> SHA1(env, eventType, x...) given that SHA1(env, x...) = type-specific ID.
Rationale: allow both masters to write the same history concurrently (while not
in split-brain), so that REPLACE INTO deduplicates the same events written twice.

* ack: SHA1(env, "ack_set"|"ack_clear", checkable.name, setTime)
* comment: SHA1(env, "comment_add"|"comment_remove", comment.name)
* downtime: SHA1(env, "downtime_start"|"downtime_end", downtime.name)
* flapping: SHA1(env, "flapping_start"|"flapping_end", checkable.name, startTime)
* notification: SHA1(env, "notification", notification.name, notificationType, sendTime)
* state: SHA1(env, "state_change", checkable.name, changeTime)
2021-11-10 17:24:55 +01:00
Alexander A. Klimov
6a75d5121b Icinga DB: make icinga:history:stream:notification#id deterministic
... i.e. UUID -> SHA1(x..., send time) given that SHA1(x...) = notification id.
Rationale: allow both masters to write the same notification history concurrently (while
not in split-brain), so that REPLACE INTO deduplicates the same events written twice.
2021-11-10 17:24:55 +01:00
Alexander A. Klimov
4f6c87402e Icinga DB: make icinga:history:stream:state#id deterministic
... i.e. UUID -> SHA1(x..., check time) given that SHA1(x...) = checkable id.
Rationale: allow both masters to write the same state history concurrently (while
not in split-brain), so that REPLACE INTO deduplicates the same events written twice.
2021-11-10 17:24:55 +01:00
Alexander A. Klimov
2bb5ed0cb3 Icinga DB: introduce icinga:history:stream:downtime#scheduled_by
... with the Downtime#scheduled_by attribute.
2021-11-10 17:16:47 +01:00
Alexander A. Klimov
2afbfa67d3 Icinga DB init. dump: flush both buffered states and state checksums
not to dump x states, but only x - (x % bulk) state checksums.
2021-11-10 17:03:00 +01:00