Commit Graph

53 Commits

Author SHA1 Message Date
Alexander A. Klimov 6b5106ffdd IcingaDB#Stop(): don't block shutdown, timeout instead 2022-03-02 16:39:44 +01:00
Alexander A. Klimov 50fee6aeb9 Icinga DB: include amount of history kept in memory in /v1/status 2022-03-02 16:39:37 +01:00
Alexander A. Klimov 8ea62f7fc7 Icinga DB: keep history in memory until written to Redis
by putting the messages into a Bulker and retrying each chunk.
2022-03-02 16:39:37 +01:00
Alexander A. Klimov 84d09876b4 Icinga DB: ensure is_reachable and severity don't miss updates
refs #9143
2022-01-25 13:33:46 +01:00
Julian Brost 31da6a56e6 Icinga DB: remove obsolete StateChangeHandler overload
This version of StateChangeHandler is no longer called anywhere as it was the
wrong function for all previous callers anyways.
2022-01-18 12:26:43 +01:00
Julian Brost cf73c6136b Icinga DB: make host problem change events update the state tables but not write state history
StateChangeHandler() is the function used when the actual hard/soft state
changes and thus also writes state history. This is not desired in this case,
instead, a runtime update should be generated, therefore call UpdateState()
instead.

refs #9063
2022-01-18 12:26:43 +01:00
Julian Brost a6d6cb788e Icinga DB: Merge SendStatusUpdate into UpdateState
Previously, both funktions did related operations but had unclear and confusing
naming:
- UpdateState updated the icinga:{host,service}:state Redis keys.
- SendStatusUpdate sent a runtime update for the icinga:{host,service}:state.

This commit merges both functions into one with a new mode parameter. The
following modes are now supported:
- Volatile: Update the icinga:{host,service}:state Redis key.
- Full: Perform the volatile state update and in addition send a corresponding
  runtime update so that this state update gets written through to the
  persistent database by a running icingadb process.
- RuntimeOnly: Special mode for callers that can ensure that a volatile update
  for the current state was already performed but has to be upgraded to a full
  update.

refs #9063
2022-01-18 12:26:43 +01:00
Noah Hilverling 73e0d6e61b Icinga DB: Make sure object relationships are handled correctly 2021-11-12 13:34:57 +01:00
Noah Hilverling 0b9317a5bf 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-05 17:01:40 +01:00
Julian Brost 6007848146 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-05 14:14:37 +01:00
Julian Brost 525dd50859 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-05 14:14:37 +01:00
Alexander A. Klimov b1714a10c2 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-02 15:00:03 +01:00
Alexander A. Klimov 5c44365c4e 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-02 15:00:03 +01:00
Julian Brost 6fa44c8e4e
Merge pull request #8941 from Icinga/bugfix/icingadb-init-all-connections-before-sync
Icinga DB: ensure all connections are ready on first use
2021-07-29 17:33:29 +02:00
Alexander Aleksandrovič Klimov afca6c001e
Merge pull request #8916 from Icinga/feature/icingadb-last_comment_id
Icinga DB: introduce Checkable#last_comment_id
2021-07-29 17:29:51 +02:00
Alexander A. Klimov 173a93c487 Split IcingaDB#SendStatusUpdate(), separate stream and history 2021-07-29 12:22:12 +02:00
Julian Brost 929ebd0f6c IcingaDB: start initial sync after all child connections are established
Icinga started the initial config sync right after the first Redis connection
was established. If any other connections would take longer to connect than
when it's first needed, queries were discarded.
2021-07-28 15:27:32 +02:00
Alexander A. Klimov 0919df5aa1 Introduce IcingaDB#connect_timeout 2021-07-27 21:59:09 +02:00
Alexander A. Klimov 37e53eaa68 Icinga DB: support TLS 2021-07-22 14:34:07 +02:00
Alexander A. Klimov e6a9631a02 Icinga DB: silence WorkQueue performance 2021-07-16 18:50:41 +02:00
Alexander A. Klimov d1e15a220c Icinga DB: use one Redis connection per config object type 2021-06-08 17:52:04 +02:00
Noah Hilverling 4005d81a43 Icinga DB: Sync state using runtime updates 2021-05-07 08:41:38 +02:00
Noah Hilverling ab04a4ee98 Icinga DB: Sync runtime updates using streams 2021-05-07 08:41:38 +02:00
Eric Lippmann b08b30ee80
Merge pull request #8684 from Icinga/feature/icingadb-signals-for-all-types
IcingaDB: Add dump signals for type dependencies and global keys and change signal pattern
2021-04-27 21:26:52 +02:00
Noah Hilverling 60412dd991 Icinga DB: Add dump signals for type dependencies and global keys 2021-04-27 12:32:14 +02:00
Julian Brost 41f7124692 Icinga DB: cache environment ID instead of recomputing it every time 2021-03-23 17:09:32 +01:00
Julian Brost a4cf81194a
Merge pull request #8650 from Icinga/feature/icingadb-delta
Icinga DB: re-insert only changed object attributes
2021-03-08 15:11:21 +01:00
Alexander A. Klimov 4eddac0e64 Icinga DB: re-insert only changed object attributes 2021-03-04 17:29:39 +01:00
Alexander A. Klimov ed57d31400 Icinga DB: HMSET the same fields only once 2021-02-24 13:37:36 +01:00
Julian Brost 2d080f14eb IcingaDB: start initial dump in callback instead of timer
Previously, the initial config dump was started in a timer executed
every 15 seconds. During the first execution of the timer, the Redis
connection is typically not established yet. Therefore, this delayed the
initial sync by up to 15 seconds.

This commit instead triggers the sync from a callback that is executed
after the connection is successfully established.

The timer is removed completely. On first glance, it looks like it would
ensure that a lost connection is reestablished, but this is handled
internally by RedisConnection. After the config has been dumped once,
that timer wouldn't ever attempt a reconnect anyways.
2021-01-20 09:31:27 +01:00
Alexander A. Klimov ff0efbc2a2 Drop IcingaDB#HandleEvents() 2020-03-04 14:37:17 +01:00
Alexander A. Klimov 54d555bd92 Drop IcingaDB#SendEvent() 2020-03-04 14:36:43 +01:00
Alexander A. Klimov c6ea9bc7fe IcingaDB: update icinga:nextupdate:* on Checkable#next_check changes
refs #7707
2019-12-10 16:11:51 +01:00
Noah Hilverling 77e02031f9
Merge pull request #7690 from Icinga/feature/flapping-acknowledgement-start-time-7689
IcingaDB: include consistent IDs, start time and end time in icinga:history:stream:{flapping,acknowledgement}
2019-12-10 14:49:17 +01:00
Alexander A. Klimov 78189d70ef IcingaDB: don't hash hashes
refs #7692
2019-12-10 11:23:05 +01:00
Alexander A. Klimov d69cb676a7 Introduce IcingaDB#GetObjectIdentifiersWithoutEnv()
refs #7692
2019-12-10 11:22:35 +01:00
Alexander A. Klimov 4f68cfd299 IcingaDB: include consistent IDs, start time and end time in icinga:history:stream:{flapping,acknowledgement}
refs #7689
2019-12-10 10:44:26 +01:00
Alexander A. Klimov 829d07aefe Introduce Checkable#acknowledgement_last_change
refs #7689
2019-12-10 10:44:23 +01:00
Alexander A. Klimov 783586978f Get rid of IcingaDB#CalculateCheckSumProperties()
refs #7691
2019-12-06 11:25:41 +01:00
Alexander A. Klimov 9a678dce8e Get rid of IcingaDB#CalculateCheckSumVars()
refs #7691
2019-12-06 11:24:33 +01:00
Alexander A. Klimov b5ada44330 Get rid of IcingaDB#CalculateCheckSumMetadata()
refs #7691
2019-12-06 11:23:13 +01:00
Alexander A. Klimov c91154a14c Get rid of IcingaDB#CalculateCheckSumString()
refs #7691
2019-12-06 10:54:11 +01:00
Alexander A. Klimov 6fc4efccc7 Get rid of IcingaDB#CalculateCheckSumArray()
refs #7691
2019-12-06 10:47:48 +01:00
Alexander A. Klimov 04e13e784d IcingaDB: populate icinga:history:stream:acknowledgement 2019-12-04 15:02:14 +01:00
Alexander A. Klimov df7184ad64 IcingaDB: populate icinga:nextupdate:* 2019-12-02 17:21:03 +01:00
Alexander A. Klimov e391c0e7b5 RedisConnection: introduce extensible priorities 2019-12-02 17:21:00 +01:00
Alexander A. Klimov ba6550dc58 IcingaDB: get rid of icinga:{subscription,event}* 2019-11-27 11:42:09 +01:00
Noah Hilverling 42f959874e IcingaDB: Add user notification history 2019-11-07 15:57:31 +01:00
Michael Friedrich 9d9804d50a Styleguide for IcingaDB 2019-11-02 18:01:31 +01:00
Michael Friedrich 631a4ee9fa Fix header guards 2019-11-02 17:24:34 +01:00