13653 Commits

Author SHA1 Message Date
Yonas Habteab
c9aba3375b
Merge pull request #10119 from Icinga/2.14Boost1.86
Bump Boost shipped for Windows to v1.86
2024-09-17 15:20:05 +02:00
Yonas Habteab
06b01cb574
Merge pull request #10125 from Icinga/output-exit-code-2.14
Mention plugin exit codes outside [0..3] in the plugin output and warning log
2024-09-17 15:18:27 +02:00
Yonas Habteab
7a04966e78
Merge pull request #10131 from Icinga/heavy-update-missing-table-relations-2.14
Update object#config_hash after all relations queries
2024-09-17 15:14:28 +02:00
Alexander Aleksandrovič Klimov
9c50fa5d94
Merge pull request #10132 from Icinga/strip-cr-in-notification-messages-2.14
Strip '\r' in notification messages to avoid 'Content-Type: application/octet-stream'
2024-09-17 15:14:00 +02:00
Yonas Habteab
cad41fa76a
Merge pull request #10129 from Icinga/malloc_info-2.14
/v1/debug/malloc_info: call malloc_info(3) if available
2024-09-17 15:13:47 +02:00
Yonas Habteab
64d5778954
Merge pull request #10130 from Icinga/timeperiod-nth-day-of-month-off-by-one-2.14
Timeperiods: fix off by one when calculating n-th last weekday of the…
2024-09-17 15:10:46 +02:00
Alexander A. Klimov
b09517e876 Bump Boost shipped for Windows to v1.86 2024-09-17 12:33:47 +02:00
Alexander A. Klimov
1446139125 PluginCheckTask::ProcessFinishedHandler(): warn about exit codes outside 0..3
in the plugin output as well, in addition to the warning log.
2024-09-17 12:33:01 +02:00
Alexander A. Klimov
0605577d4d Make ProcessResult#ExitStatus and CheckResult#exit_status 64-bit ints
so that they can hold Windows exit codes like 3221225477 (>2147483647).
2024-09-17 12:33:01 +02:00
Alexander A. Klimov
2722deb6aa /v1/debug/malloc_info: call malloc_info(3) if available
The GNU libc function malloc_info(3) provides memory allocation and usage
statistics of Icinga 2 itself.
2024-09-17 12:32:52 +02:00
Julian Brost
3247e83957 Timeperiods: fix off by one when calculating n-th last weekday of the month
A day specification like "monday -1" refers to the last Monday of the month.
However, there was an off by one if the first day of the next month is the same
day of the week, i.e. a Monday in this example.

LegacyTimePeriod::FindNthWeekday() picks a day to start the search for the day
in question. When given a negative n to search for the n-th last day, it
wrongly used the first day of the following month as the start and counted it
as if it was within the current month. This resulted in a 1/7 chance that the
result was one week too late.

This is fixed by using the last day of the current month instead.
2024-09-17 12:32:10 +02:00
Yonas Habteab
36e8c9c8fd Update object#config_hash after all relations queries 2024-09-17 12:31:38 +02:00
Robert Scheck
bde4257793 Strip '\r' in notification messages to avoid 'Content-Type: application/octet-stream'
Without this patch, an accidential `\r` in e.g. `$NOTIFICATIONCOMMENT`
leads to a `Content-Type: application/octet-stream` header in e-mails.
The accidential `\r` might slip in usually using Icinga/Nagios apps...
2024-09-17 12:29:56 +02:00
Yonas Habteab
31c42dc2ca
Merge pull request #10145 from Icinga/formatdatetime-2.14
Overhaul Utility::FormatDateTime()
2024-09-16 12:41:57 +02:00
Yonas Habteab
27a4a25c9f
Merge pull request #10146 from Icinga/JsonRpcConnection-2.14
JsonRpcConnection#Send*(): discard messages ASAP once shutting down
2024-09-16 11:59:19 +02:00
Yonas Habteab
96839d829b ApiListener: Reorder logging in ApiTimerHandler() 2024-09-03 16:49:02 +02:00
Yonas Habteab
b9b3e7a925 ApiListener: Catch & supress clients runtime errors 2024-09-03 16:49:02 +02:00
Yonas Habteab
561aedab1d JsonRpcConnection: Raise an exception when trying to send to disconnected clients 2024-09-03 16:49:02 +02:00
Julian Brost
02334c5f29 Make sure log file is reopened when ApiListener::ReplayLog() returns 2024-09-03 16:49:02 +02:00
Yonas Habteab
b0b41b1aff Defer: Allow empty initialization & add SetFunc() method 2024-09-03 16:49:01 +02:00
Yonas Habteab
5f2d31bf3c Use Defer class for cleanup in ApiListener::ReplayLog() 2024-09-03 16:49:01 +02:00
Alexander A. Klimov
9a0c7d7c75 ApiListener#ReplayLog(): stop reading files ASAP on send error 2024-09-03 16:49:01 +02:00
Alexander A. Klimov
a6946f9dbf JsonRpcConnection#Send*(): discard messages ASAP once shutting down
Especially ApiListener#ReplayLog() enqueued lots of messages into
JsonRpcConnection#{m_IoStrand,m_OutgoingMessagesQueue} (RAM) even if
the connection was shut(ting) down. Now #Disconnect() takes effect ASAP.
2024-09-03 16:49:01 +02:00
Alexander A. Klimov
81da1cdb26 JsonRpcConnection#Disconnect(): spawn coroutine only if necessary
by checking the now atomic #m_ShuttingDown outside of it.
2024-09-03 16:49:01 +02:00
Julian Brost
a24a43e4d0 Utility::FormatDateTime(): provide an overload for tm*
This allows the function to be used both with a double timestamp or a pointer
to a tm struct. With this, a similar implementation inside the tests can simply
use our regular function.
2024-09-03 15:26:51 +02:00
Julian Brost
542b02621c Utility::FormatDateTime(): handle invalid format strings on Windows
On Windows, the strftime() function family invokes an invalid parameter handler
when the format string is invalid (see the "Remarks" section in their
documentation). std::put_time() shows the same behavior as it uses
_wcsftime_l() internally. The default invalid parameter handler may terminate
the process, which can be a problem given that the format string can be
specified by the user from the Icinga DSL.

Thus, temporarily set a thread-local no-op handler to disable the default one
allowing the program to continue. This then simply results in the function
returning an error which then results in an exception as we ask the stream to
throw one.

See also:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/strftime-wcsftime-strftime-l-wcsftime-l?view=msvc-170
https://learn.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation?view=msvc-170
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/set-invalid-parameter-handler-set-thread-local-invalid-parameter-handler?view=msvc-170
2024-09-03 15:26:51 +02:00
Julian Brost
6887ac6970 Utility::FormatDateTime(): handle errors from strftime()
So far, the return value of strftime() was simply ignored and the output buffer
passed to the icinga::String constructor. However, there are error conditions
where strftime() returns 0 to signal an error, like if the buffer was too small
for the output. In that case, there's no guarantee on the buffer contents and
reading it can result in undefined behavior. Unfortunately, returning 0 can
also indicate success and strftime() doesn't set errno, so there's no reliable
way to distinguish both situations. Thus, the implementation now returns the
empty string in both cases.

I attempted to use std::put_time() at first as that allows for better error
handling, however, there were problems with the implementation on Windows (see
inline comment), so I put that plan on hold at left strftime() there for the
time being.
2024-09-03 15:26:51 +02:00
Julian Brost
541fd41799 Utility::FormatDateTime(): use localtime_s() on Windows
localtime() is not thread-safe as it returns a pointer to a shared tm struct.
Everywhere except on Windows, localtime_r() is used already which avoids the
problem by using a struct allocated by the caller for the output.

Windows actually has a similar function called localtime_s() which has the same
properties, just with a different name and order of arguments.
2024-09-03 15:26:51 +02:00
Julian Brost
1bc0648b3c Utility::FormatDateTime(): use boost::numeric_cast<>()
The previous implementation actually had undefined behavior when called with a
double that can't be represented as time_t. With boost::numeric_cast, there's a
convenient cast available that avoids this and throws an exceptions on
overflow.

It's undefined behavior ([0], where the implicit conversion rule comes into
play because the C-style cast uses static_cast [1] which in turn uses the
imlicit conversion as per rule 5 of [2]):

> A prvalue of floating-point type can be converted to a prvalue of any integer
> type. The fractional part is truncated, that is, the fractional part is
> discarded.
>
> * If the truncated value cannot fit into the destination type, the behavior
>   is undefined (even when the destination type is unsigned, modulo arithmetic
>   does not apply).

Note that on Linux amd64, the undefined behavior typically manifests itself in
the result being the minimal value of time_t which then results in localtime_r
failing with EOVERFLOW.

[0]: https://en.cppreference.com/w/cpp/language/implicit_conversion#Floating.E2.80.93integral_conversions
[1]: https://en.cppreference.com/w/cpp/language/explicit_cast
[2]: https://en.cppreference.com/w/cpp/language/static_cast
2024-09-03 15:26:51 +02:00
Julian Brost
46f1bd5846 Add tests for Utility::FormatDateTime() 2024-09-03 15:26:51 +02:00
Yonas Habteab
eec1d242c3
Merge pull request #10108 from Icinga/gha2143
Update GitHub actions
2024-09-03 14:56:38 +02:00
Alvar Penning
7cbf2e1c2c GHA: Unbreak Windows Tests
As seen in the recent GHA run for #10102, the two Windows Actions have
failed. The output log contains:

> DEBUG:   27+  >>>> ctest.exe -C "${env:CMAKE_BUILD_TYPE}" -T test -O $env:ICINGA2_BUILDPATH/Test.xml
> --output-on-failure --log_level=all
> CMake Error: Unknown argument: --log_level=all
> CMake Error: Run 'ctest --help' for all supported options.

After consulting ctest(1), older versions included, I have never found a
mention of the "--log_level" flag. Since the useful
"--output-on-failure" flag is already set, which will "[o]utput anything
outputted by the test program if the test should fail", I do not see any
further reason for more logging information.

This flag was introduced in 7665143afa500dd589546665124293b9c1206265,
but I have not found any reasoning for the flag in particular.
2024-08-06 11:30:03 +02:00
Alexander Aleksandrovič Klimov
b68580338b GHA: add openSUSE 15.6 and SLES 15.6 2024-08-06 10:59:34 +02:00
Alexander A. Klimov
449e5c026d GHA: drop EOL EL7 2024-08-06 10:59:34 +02:00
Alexander Aleksandrovič Klimov
6a7b440cfd
Merge pull request #10084 from Icinga/win2143
Bump Windows deps
2024-06-12 13:03:05 +02:00
Alexander A. Klimov
d856cab9d9 Bump OpenSSL shipped for Windows to v3.0.14 2024-06-12 10:25:11 +02:00
Alexander A. Klimov
3a3454e1b5 Bump Boost shipped for Windows to v1.85
Note: For doc/21-development.md use:

perl -pi -e 's/(boost[-\w]*?1[-_]?)84/${1}85/g' doc/21-development.md
2024-06-12 10:25:11 +02:00
Alexander Aleksandrovič Klimov
62a92c10b5
Merge pull request #10075 from Icinga/gha2143
Update GitHub actions
2024-06-10 10:59:37 +02:00
Alexander Aleksandrovič Klimov
39be31c305 CMakeLists.txt: set(CPACK_WIX_INSTALL_SCOPE NONE)
to stick to CMake pre-v3.29 behavior. CMake v3.29 introduces CPACK_WIX_INSTALL_SCOPE. Its default conflicts with the ALLUSERS property in our icinga-installer/icinga2.wixpatch.cmake.
2024-06-07 15:50:54 +02:00
Alexander Aleksandrovič Klimov
8b6c73166c GHA: Docker: don't run on support/* branches
PRs to them are already covered and we don't need support* image tags.
2024-06-07 15:49:10 +02:00
Alexander Aleksandrovič Klimov
469bc7e9fd GHA: drop Debian 10
which will be EOL in 2.5 months.
2024-06-07 15:49:10 +02:00
Alexander Aleksandrovič Klimov
00d77443a0 GHA: add upcoming Fedora 40 2024-06-07 15:49:10 +02:00
Alexander Aleksandrovič Klimov
a00e57c06b GHA: add upcoming Ubuntu 24.04 2024-06-07 15:49:10 +02:00
Alexander A. Klimov
6ba41b01e4 GHA AUTHORS check: handle PRs from forks
where the ref names differ compared to own PRs. Instead refer to the base branch and the head branch via generic HEAD^<parent number> where HEAD is a merge commit.
2024-06-07 15:49:10 +02:00
Alexander Aleksandrovič Klimov
fc4ff8b7af
Merge pull request #9971 from Icinga/2142
Icinga 2.14.2
v2.14.2
2024-01-17 19:49:18 +01:00
Alexander Aleksandrovič Klimov
d6a2528af5
Merge pull request #9970 from Icinga/2142backport
Log HTTP request processing time and ship Boost 1.84 on Windows
2024-01-17 19:11:54 +01:00
Alexander Aleksandrovič Klimov
37d9ae752f
Merge pull request #9969 from Icinga/influx-disk-9948-214
Influx DB: truncate timestamps to whole seconds to save disk space
2024-01-17 19:04:39 +01:00
Alexander A. Klimov
5bb2024976 Icinga 2.14.2 2024-01-17 17:53:00 +01:00
Alexander A. Klimov
fd5f3c57d9 Bump Boost shipped for Windows to v1.84
Note: For doc/21-development.md use:

perl -pi -e 's/(boost[-\w]*?1[-_]?)83/${1}84/g' doc/21-development.md

(cherry picked from commit 77313d751c8ae78f0114f62c248455bfadf47041)
2024-01-17 17:11:10 +01:00
Alexander A. Klimov
6817a148bd HttpServerConnection: log request processing time as well
(cherry picked from commit b6874cc8d40336fbc9eb6c60e9d1be9313365a58)
2024-01-17 17:11:10 +01:00