5047 Commits

Author SHA1 Message Date
Julian Brost
b1536eac6f Catch exceptions thrown by RunWorker on Windows
The same is already done on other platforms in line 529.
2021-05-26 08:52:37 +02:00
Julian Brost
7511a5c3fc Only handle event::SetSuppressed{Notifications,NotificationTypes} within the local zone
Note that even when passing `nullptr` as target zone to `RelayMessage()`, the
cluster message will still be sent to the parent zone. These incoming messages
will now be rejected by the parent nodes. At the moment, there's no way to only
send within the local zone.
2021-05-26 08:52:05 +02:00
Julian Brost
c0c7d52921 Retry file rename operations on Windows for some errors 2021-05-26 08:51:22 +02:00
Alexander A. Klimov
83eba2b316 ConfigObjectUtility#CreateObject(): check config objects for duplicates
... not to delete already existing objects during a trial of re-creation.

refs #7726
2021-05-25 19:39:17 +02:00
Alexander Aleksandrovič Klimov
04d8eee3e5
Merge pull request #8793 from Icinga/bugfix/211boost174
Support Boost 1.74
2021-05-25 15:26:19 +02:00
Julian Brost
50820f1a73 Provide a conversion function from icinga::String to boost::string_view
Boost.Beast changed the signature of
boost::beast::http::basic_fields::set in version 1.74 so that no longer
allows passing an icinga::String instance as value. This adds a
conversion function so that it works again.
2021-05-20 16:28:30 +02:00
Julian Brost
058d267397 Use content_length method for setting the Content-Length header
Boost.Beast changed the signature of the previously used generic `set`
method so that it no longer accepts integer types, however there is
alreay a more specific method for setting the Content-Length header, so
use this one instead.
2021-05-20 16:28:30 +02:00
Louis Sautier
514a4e326f Fix ‘fs::copy_option’ has not been declared with boost 1.74.0
It was deprecated in
f199152b7d
2021-05-20 16:28:30 +02:00
Julian Brost
398a5baf70 Remove unused function declarations in tlsutility.hpp
These were introduced in c510fe4dfed0f65824bb259433faa0988caa2447, probably
when resolving a merge conflict. However, these functions do not exist in 2.11,
but refer to the Array type which is not included in the header, leading to
non-unity build failing.

This commit simply removes these declarations and thus restores non-unity
builds in 2.11.
2021-05-20 14:25:59 +02:00
Noah Hilverling
d17b4ecc4b
Merge pull request #8560 from Icinga/bugfix/children-recover-too-late
On recovery: re-check children
2020-12-15 13:11:46 +01:00
Noah Hilverling
9c433044cc Build fix: Use correct shared pointer implementation 2020-12-15 13:00:23 +01:00
Julian Brost
c510fe4dfe Verify certificates against CRL before renewing them
When a CRL is specified in the ApiListener configuration, Icinga 2 only
used it when connections were established so far, but not when a
certificate is requested. This allows a node to automatically renew a
revoked certificate if it meets the other conditions for auto-renewal
(issued before 2017 or expires in less than 30 days).
2020-12-15 10:38:37 +01:00
Alexander A. Klimov
4b0313d3f3 On recovery: re-check children 2020-12-11 16:40:29 +01:00
Alexander A. Klimov
3c15e71e19 Don't fire suppressed notifications if last parent recovery >= last check result 2020-12-11 16:40:29 +01:00
Noah Hilverling
03b728b83e Fix runtime config updates not working for objects without zone
refs #8533
2020-12-10 17:07:04 +01:00
Julian Brost
905cf5aa65 Use ERR_error_string_n() instead of ERR_error_string()
Explicitly pass the actual length of the buffer to avoid overflows.
2020-12-09 12:23:07 +01:00
Julian Brost
3b37867d2e Increase size of buffer for OpenSSL error messages
According to man 3 ERR_error_string, "buf must be at least 256 bytes
long", therefore increase the buffer size to 256 everywhere.
2020-12-09 12:23:07 +01:00
Julian Brost
64a49ee3a1 Remove std::string to_string(const errinfo_openssl_error& e)
The function was never used and it's implementation contains a bug where
a buffer of too small size is used as a paramter to ERR_error_string.
According to the `man 3 ERR_error_info`, the buffer has to be at least
256 bytes in size.

Also the function seems of limited use as it allows to output the tag
object used with additional error information for exceptions in Boost.
However, you boost::get_error_info<>() just returns the value type but
not the full tag object from the exception.
2020-12-09 12:22:52 +01:00
Julian Brost
072434f3f3 Remove SpinLock
No longer needed as its only user now uses std::mutex.
2020-11-27 11:24:17 +01:00
Julian Brost
7d546aa2d8 ApiListener: merge new config validation and actication functions
Merge AsyncTryActivateZonesStage and TryActivateZonesStageCallback and
name the result TryActivateZonesStage. The old split was a leftover from
the one being a callback function with no actual meaningful separation.
2020-11-27 11:24:17 +01:00
Julian Brost
a96e6c3861 Use std::mutex instead of Spinlock 2020-11-27 11:24:17 +01:00
Julian Brost
3081d9942d API filesync: wait for validation process to exit
This avoid having to pass a lock implictly using the captured variables
of a lambda.
2020-11-27 11:24:17 +01:00
Julian Brost
fde51ed9f7 Add Process::WaitForResult to allow waiting for the process to finish 2020-11-27 11:24:17 +01:00
Julian Brost
6b8a018afb
Merge pull request #8486 from Icinga/bugfix/config-sync-only-remove-files-if-timestamp-changed
Config sync: Only remove files, if timestamp changed
2020-11-16 17:36:42 +01:00
Noah Hilverling
f184c1bc57 Config sync: Only remove files, if timestamp changed 2020-11-16 17:33:20 +01:00
Noah Hilverling
c40a4c5cbc
Merge pull request #8475 from Icinga/bugfix/replay-log-blocks
Start ApiListener#SyncClient() in the thread pool
2020-11-16 14:34:40 +01:00
Noah Hilverling
cd819e3801
Merge pull request #8473 from Icinga/bugfix/message-routing-for-global-zones-2.11
Fix cluster message routing for global zones
2020-11-16 14:32:52 +01:00
Julian Brost
de44bf5e71 Close anonymous connections after 10 seconds
Anonymous connections are normally only used for requesting a
certificate and are closed after this request is received. However, the
request is only sent if the child has successfully verified the
certificate of its parent so that it is an authenticated connection from
its perspective. In case this verification fails, both ends view it as
an anonymous connection and never actually use it but attempt a
reconnect after 10 seconds leaking the connection. Therefore close it
after a timeout.
2020-11-13 16:33:04 +01:00
Alexander A. Klimov
ba87ae8109 Start ApiListener#SyncClient() in the thread pool
... not hosting the coroutines not to block them.

Otherwise a large replay log would block messages sending
until the peer disconnects us.
2020-11-12 14:14:20 +01:00
Julian Brost
1adfe851b1 Fix cluster message routing for global zones
RelayMessageOne used to relay the message only to one other endpoint for
other zones, which is fine, as long as the target zone is a child/parent
zone but breaks if the target zone is a global one. In this case, the
message has to be forwarded within the local zone as well as to one node
in each child zone.
2020-11-12 09:49:56 +01:00
Noah Hilverling
d80eb89908
Merge pull request #8457 from Icinga/bugfix/replay-object-deletion-2.11
Log config object deletions to replay log
2020-11-10 11:31:49 +01:00
Alexander Aleksandrovič Klimov
97cda44e7d
Merge pull request #8399 from Icinga/feature/one-connection
ApiListener#NewClientHandlerInternal(): reject connections from already connected endpoints
2020-11-10 11:17:21 +01:00
Alexander Aleksandrovič Klimov
3c97ab6d47
Merge pull request #8454 from Icinga/feature/http-status-codes-in-icinga-mainlog-7053
Include HTTP status codes in log
2020-11-10 11:13:26 +01:00
Noah Hilverling
b2a235c54a API: Don't accept object updates for unknown zone 2020-11-09 16:21:40 +01:00
Julian Brost
b330d8a74e Log config object deletions to replay log
The initial config object sync for each new connection (in
`ApiListener::SendRuntimeConfigObjects()`) only considers currently
existing objects and has no way to pass the information that objects
were deleted in the meantime.

This commit logs config object deletions to the replay log if required
so that there is a chance that it will be propagated to nodes that were
offline when the deletion happened.

Note that this can only be considered a workaround as the replay log
might be pruned or could even be completely disabled. Also, there still
seems to be a race-condition between the config sync and replay log of
multiple new connections at the same time.
2020-11-09 15:55:51 +01:00
Alexander A. Klimov
29e5d7def7 Include HTTP status codes in log
refs #7053
2020-11-09 10:20:13 +01:00
Alexander A. Klimov
38110e55d3 ApiListener#NewClientHandlerInternal(): reject connections from already connected endpoints 2020-10-26 15:20:58 +01:00
Noah Hilverling
c5b4b73de0 IDO: Do not log stats, if paused 2020-10-15 09:58:39 +02:00
Alexander A. Klimov
8fff42c73d Buildfix 2020-10-13 16:36:10 +02:00
Alexander Aleksandrovič Klimov
5ee7eb8f29
Merge pull request #8316 from Icinga/bugfix/ido-hash-groups
*DbObject#CalculateConfigHash(): sort groups to be hashed
2020-10-13 14:54:05 +02:00
Julian Brost
c5ce54918e Catch exceptions in the thread running HandleConfigUpdate
With dc3062a9b06fed69cdbb1508ace6eb2f77f87553, exceptions in this code
path were no longer caught properly. This commit restores exception
handling for this function.
2020-10-13 14:27:47 +02:00
Alexander Aleksandrovič Klimov
dd8b786b3b
Merge pull request #8292 from Icinga/bugfix/icinga2-doesn-t-close-connections-7203-211
Add timeout for boost::asio::ssl::stream#async_shutdown()
2020-10-13 13:58:39 +02:00
Alexander Aleksandrovič Klimov
3b398fd7bb
Merge pull request #8300 from Icinga/bugfix/reminder-notifications-before-suppressed-8201
Don't send reminder notifications before suppressed ones
2020-10-13 13:57:26 +02:00
Alexander Aleksandrovič Klimov
727a9a61f0
Merge pull request #8298 from Icinga/bugfix/ido-commit-25000
IDO MySQL: actually COMMIT after 25000 async queries
2020-10-13 13:55:13 +02:00
Alexander Aleksandrovič Klimov
9e40e39b56
Merge pull request #8305 from Icinga/bugfix/do-not-update-customvar-status-on-heavy-config-update
Do not upsert customvar status on heavy config update
2020-10-13 13:53:41 +02:00
Alexander Aleksandrovič Klimov
a237dedaea
Merge pull request #8325 from Icinga/feature/improve-ido-logging
Improve new IDO logging
2020-10-13 13:52:11 +02:00
Alexander A. Klimov
cb00a7fd6a *DbObject#CalculateConfigHash(): sort groups to be hashed
... to ensure consistent hashes across config reloads.

This will likely cause a heavy update once for all objects in >1 group,
but it will ensure that this happens the last time.
2020-10-13 13:47:49 +02:00
Julian Brost
21b30322c9
Merge pull request #8308 from Icinga/bugfix/configsyncstagelock-unlock-owner
Make ApiListener::m_ConfigSyncStageLock a SpinLock
2020-10-13 13:37:08 +02:00
Alexander Aleksandrovič Klimov
e62c6c7f05
Merge pull request #8303 from Icinga/bugfix/revert-fix-duplicate-entry-error
Revert: Fix duplicate entry error
2020-10-13 12:27:53 +02:00
Noah Hilverling
22c14fd964 IDO: Always insert customvar status on heavy config update 2020-10-13 08:54:58 +02:00