Eric Lippmann
81692395b1
Use own connections for heartbeat and HA
...
Use dedicated connections for heartbeat and HA to ensure that
heartbeats are always processed and the instance table is updated.
Otherwise, the connections can be too busy due to the
synchronization of configuration, status, history, etc.,
which can lead to handover / takeover loops because the heartbeat
is not read while HA gets stuck when updating the instance table.
2021-11-12 17:46:54 +01:00
Alexander A. Klimov
fecf332b8e
RuntimeUpdates#Sync(): force FIFO for config updates
...
so they don't interfer.
Co-authored-by: Eric Lippmann <eric.lippmann@icinga.com>
2021-11-12 12:35:12 +01:00
Eric Lippmann
9a47f50828
Raise expectedRedisSchemaVersion
2021-11-09 15:11:09 +01:00
Eric Lippmann
ccda48234e
Use custom logger for accessing the interval for periodic logging
2021-11-05 17:57:22 +01:00
Eric Lippmann
6232773943
Use debug instead of info for some log messages
...
These log messages are not relevant for the info level.
2021-11-05 17:52:48 +01:00
Eric Lippmann
313e3cc735
Log time taken for the config and initial state sync
2021-11-05 17:52:11 +01:00
Eric Lippmann
986e685ee0
Allow to configure interval for periodic logging
2021-11-05 17:18:05 +01:00
Eric Lippmann
dc7511cd25
Don't log if context is canceled
2021-11-05 17:16:57 +01:00
Julian Brost
74fb238923
Increase Redis schema version
...
PR #391 and icinga2#9036 changed where the environment is read from in an
incompatible way, therefore the schema version bump.
2021-11-03 15:47:38 +01:00
Julian Brost
3342191b5e
Exit on environment ID changes
...
There's a small risk that when the environment ID changes, Icinga DB could
update write into the wrong environment in the database. Therefore,
https://github.com/Icinga/icinga2/pull/9036 introduced a new default
environment ID based on the CA public key so that there should be no cases
where it's required to change the actual environment ID. So if this happens
nonetheless, just bail out.
2021-11-03 15:47:38 +01:00
Eric Lippmann
a081927672
Only sync entities that belong to the current environment
...
Previously, we selected each entity from the database.
Now we only select entities that belong to the current environment.
2021-11-03 15:47:38 +01:00
Eric Lippmann
084e0409bc
Restart HA after environment change
...
If the environment changes during runtime, we have to restart HA
in order to stop a possibly running config sync and start a new
one.
2021-11-03 14:51:19 +01:00
Eric Lippmann
e74b09daa1
Use synctx instead of ctx
...
Otherwise, code that is executed with ctx will not be cancelled if
the synchronization is cancelled, e.g. in the case of heartbeat
handovers.
2021-11-03 14:51:13 +01:00
Julian Brost
cd9e683faa
Merge pull request #393 from Icinga/feature/history-ha
...
Sync history independent of HA
2021-11-03 14:17:14 +01:00
Julian Brost
f290a0c9b7
Merge pull request #392 from Icinga/feature/history-deterministic-ids
...
Make {NotificationHistory,StateHistory,History*}#Id UUID -> SHA1
2021-11-03 13:18:11 +01:00
Alexander A. Klimov
47d5e80a05
Raise expectedRedisSchemaVersion 1 -> 2
2021-11-03 12:15:25 +01:00
Alexander A. Klimov
660d8c7d5a
Sync history independent of HA
2021-10-29 20:32:04 +02:00
Eric Lippmann
e433aa7ec3
Move custom var sync to a new method
2021-10-26 09:31:41 +02:00
Eric Lippmann
5b18a7dd93
Respect context in custom var sync
2021-10-26 09:31:41 +02:00
Eric Lippmann
b48792cf36
Handle flat custom vars explicitly in runtime updates
...
This also requires explicit handling of custom variables as we need
to multiplex the original values to handle flat custom variables.
2021-10-26 09:31:41 +02:00
Eric Lippmann
4d65c62f77
Handle contracts.Initer in common.NewSyncSubject()
...
contracts.EntitiyFactoryFunc.WithInit() checked for
contracts.Initer every time.
Now it is only done once in common.NewSyncSubject().
2021-10-26 09:31:36 +02:00
Eric Lippmann
cacc710ff6
Use ExpandCustomvars() and synctx instead of ctx
2021-10-26 09:27:00 +02:00
Alexander Aleksandrovič Klimov
d9c626ced8
Merge pull request #383 from Icinga/feature/icingadb-schema-version
...
Only do anything while icinga:schema version meets our expectations
2021-10-25 15:49:58 +02:00
Alexander A. Klimov
b5e024e68d
Sync state runtime updates ASAP
...
I.e. don't wait for the complete initial sync first.
2021-10-14 10:15:28 +02:00
Eric Lippmann
c9914a1668
Notify systemd that Icinga DB finished starting up
2021-10-13 09:46:12 +02:00
Eric Lippmann
537a4cf37f
Allow to configure the logging output
2021-10-13 09:46:12 +02:00
Eric Lippmann
a9afcea25c
Allow systemd-journald (and console) as log outputs
2021-10-13 09:46:12 +02:00
Eric Lippmann
9e49b62c4d
Use the app name as the default logger name
2021-10-13 09:46:12 +02:00
Eric Lippmann
bdeed69337
Move logging from internal to pkg
2021-10-13 09:20:55 +02:00
Alexander A. Klimov
17dc99b078
Only do anything while icinga:schema version meets our expectations
...
... not to work on unknown data structure.
2021-10-06 12:11:16 +02:00
Ravi Kumar Kempapura Srinivasa
f8e9290618
Use child loggers
2021-09-28 17:30:11 +02:00
Ravi Kumar Kempapura Srinivasa
0aa646c218
Use child loggers for Redis and database
2021-09-28 17:30:11 +02:00
Ravi Kumar Kempapura Srinivasa
d3cdc8023b
Use logger from logging pkg
...
This now also uses info as the default log level and enables the
configuration of the default log level as well as log levels of
the child loggers that will be implemented in a later commit.
2021-09-28 17:30:11 +02:00
Alexander A. Klimov
3e452d9561
On shutdown: give up HA handover after 3s, not 5m
...
... not to hang for 5m if DB is down.
refs #350
2021-09-22 15:42:58 +02:00
Alexander A. Klimov
ea7668d99a
HA#Close(): allow custom context
...
refs #350
2021-09-22 14:12:27 +02:00
Eric Lippmann
ffd66c5333
Add newline before return
2021-08-09 10:30:53 +02:00
Alexander A. Klimov
f06bad5f23
Don't append(x,y) if x is not to be modified
...
... as append(x,y) would modify x.
refs #324
2021-08-03 18:59:40 +02:00
Eric Lippmann
a936d26c75
Get the last IDs of the runtime update streams before starting anything else
...
Otherwise updates may be lost.
2021-08-03 14:06:55 +02:00
Eric Lippmann
e35a1609fc
Stream state updates from icinga:runtime:state
...
Icinga now sends runtime updates in two separate channels,
icinga:runtime for config updates and icinga:runtime:state for
state updates. With this change, Icinga DB reads from these two
streams. This is a preparation so that state updates can be
streamed directly after a (re)start of Icinga or Icinga DB without
waiting for the config sync, as it is currently done.
2021-08-03 14:06:55 +02:00
Alexander A. Klimov
6a17911e6b
Assert the database schema of the expected version being present
2021-07-06 19:00:20 +02:00
Eric Lippmann
752db18a91
Print stack traces
2021-06-21 13:20:44 +02:00
Eric Lippmann
dac7cceff7
Use Info() instead of Infof() if no format string
2021-06-21 12:13:24 +02:00
Eric Lippmann
03e899701e
Add custom vars to the runtime update sync
...
The customvar runtime update sync may change because the customvar
flat runtime update sync is not yet implemented.
2021-05-31 13:59:13 +02:00
Alexander A. Klimov
64433ec674
Make channel for signal.Notify() buffered
2021-05-28 14:24:36 +02:00
Alexander A. Klimov
621c1b9537
Ensure context cancellation
2021-05-28 14:24:36 +02:00
Noah Hilverling
44c734f72d
Improve database and HA logging
2021-05-25 09:49:48 +02:00
Alexander A. Klimov
b31e012cf0
Sync overdue indicators
2021-05-12 18:51:13 +02:00
Eric Lippmann
52e5eb774e
Sync customvar flat
2021-05-11 16:40:08 +02:00
Eric Lippmann
442e04bbf1
Use type common.SyncSubject
2021-05-11 16:40:08 +02:00
Eric Lippmann
feda71f06d
Merge pull request #49 from lippserd/bugfix/ha-error-handling
...
Handle HA errors
2021-05-07 14:54:33 +02:00
Julian Brost
ae743817da
Add comment explaining the purpose of ha.Close()
2021-05-07 14:51:58 +02:00
Julian Brost
e0d66fe0ee
Exit with an error code if not exiting due to a signal
...
Icinga DB should not exit with code 0 if it does so due to an error.
2021-05-07 14:51:58 +02:00
Eric Lippmann
a1ceeeb9eb
Merge pull request #36 from lippserd/feature/runtime-updates
...
Implement runtime updates
2021-05-07 14:37:56 +02:00
Eric Lippmann
345bcb952f
Runtime updates must wait for config sync to complete
2021-05-07 12:04:41 +02:00
Noah Hilverling
91a8228e2d
Implement runtime updates
2021-05-07 12:04:41 +02:00
Julian Brost
3649b367e1
Handle HA errors
2021-05-07 11:46:45 +02:00
Alexander A. Klimov
ff6ae994d2
Remove always-false if
2021-05-07 11:06:54 +02:00
Julian Brost
a7e5395f66
Read icinga:dump stream and respect dump signals
2021-05-03 11:19:26 +02:00
Julian Brost
ab24bdd1f7
Main loop: return if ctx has an error
...
If ctx.Done(), there's no point in looping again.
2021-04-28 16:05:56 +02:00
Julian Brost
d138b8e0ac
Handle SIGINT/SIGTERM/SIGHUP
...
On any of these signals, HA removes the row of the local instance from
icingadb_instance. This allows another instance to take over immediately.
2021-04-28 12:01:02 +02:00
Eric Lippmann
4fbcd4c90f
Move factories away from main and use v1.Factories
2021-04-27 23:36:43 +02:00
Alexander A. Klimov
5e473e8b37
main(): don't panic on (intentional) context cancel
2021-04-26 14:15:10 +02:00
Eric Lippmann
a9c6cdabc9
Remove comment
2021-04-23 11:50:27 +02:00
Eric Lippmann
dfb7ea5dc9
Remove customvar_flat sync draft
2021-04-23 11:34:07 +02:00
Eric Lippmann
0c8a9139b5
Merge pull request #28 from lippserd/bugfix/delta-race
...
Delta#start(): avoid a race across maps by using a mutex
2021-04-19 16:20:42 +02:00
Alexander A. Klimov
fac47fb330
Delta: don't over-lock
2021-04-12 17:41:18 +02:00
Alexander A. Klimov
7ccf627df6
Sync history
2021-04-12 13:28:03 +02:00
Eric Lippmann
63d8bf8e24
Merge pull request #15 from lippserd/feature/timeperiod
...
Sync timeperiods as well
2021-03-30 10:12:33 +02:00
Eric Lippmann
9525ef476e
Merge pull request #13 from lippserd/feature/notification
...
Sync notifications as well
2021-03-23 10:09:06 +01:00
Eric Lippmann
b9673e1a94
Merge pull request #11 from lippserd/feature/comment
...
Sync comments as well
2021-03-23 10:08:01 +01:00
Alexander A. Klimov
fd2e068de6
Sync timeperiods as well
2021-03-22 14:07:52 +01:00
Alexander A. Klimov
7ab45082ad
Sync notifications as well
2021-03-22 14:06:51 +01:00
Alexander A. Klimov
3ec88ac53d
Sync comments as well
2021-03-22 14:04:58 +01:00
Alexander A. Klimov
b90bc86bb4
Sync zones as well
2021-03-22 14:03:46 +01:00
Eric Lippmann
49d50a779e
Merge pull request #12 from lippserd/feature/downtime
...
Sync downtimes as well
2021-03-22 13:37:35 +01:00
Eric Lippmann
dd1fad4b13
Merge pull request #10 from lippserd/feature/command
...
Sync commands as well
2021-03-22 13:36:46 +01:00
Eric Lippmann
9f936eba95
Merge pull request #7 from lippserd/feature/groups
...
Sync groups as well
2021-03-22 13:36:12 +01:00
Alexander A. Klimov
13c672ce6e
Sync downtimes as well
2021-03-18 13:56:07 +01:00
Alexander A. Klimov
a56d312c81
Sync commands as well
2021-03-18 13:51:33 +01:00
Eric Lippmann
e4539d90fc
Merge pull request #8 from lippserd/feature/endpoint
...
Sync endpoints as well
2021-03-18 13:42:20 +01:00
Alexander A. Klimov
71d1b4a9f4
Sync endpoints as well
2021-03-18 12:32:09 +01:00
Alexander A. Klimov
055e63e272
Sync groups as well
2021-03-18 12:31:11 +01:00
Alexander A. Klimov
0dd5e54b14
Sync users as well
2021-03-18 12:19:23 +01:00
Alexander A. Klimov
3a66f0372c
Introduce CustomvarMeta
2021-03-18 12:19:20 +01:00
Eric Lippmann
c2fe0dfe7c
Merge pull request #16 from lippserd/feature/channels
...
Make channels more specific
2021-03-17 10:03:24 +01:00
Eric Lippmann
f9648b00c5
Merge pull request #14 from lippserd/feature/url
...
Sync URLs as well
2021-03-17 10:02:20 +01:00
Eric Lippmann
c5f1b88c0c
Merge pull request #4 from lippserd/feature/initer
...
Make NameCiMeta an Initer
2021-03-17 09:56:10 +01:00
Alexander A. Klimov
4dffbad76e
Make channels more specific
2021-03-15 16:34:58 +01:00
Alexander A. Klimov
aa3dfc2afc
Sync URLs as well
2021-03-12 16:44:19 +01:00
Alexander A. Klimov
8cd62118b2
Auto-init Initers
2021-03-12 10:55:12 +01:00
Julian Brost
a474c83651
Replace persisted instance ID with a random one and remove old rows from icingadb_instance
2021-03-08 13:01:52 +01:00
Eric Lippmann
6ca9d36c8b
Add cmd
2021-03-04 00:50:24 +01:00