From a038f513aaeaa9d4528dc39887cc0421b275dc0f Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Wed, 7 Jul 2021 15:28:50 +0200 Subject: [PATCH 1/5] Bump OpenSSL to 1.1.1k --- doc/win-dev.ps1 | 2 +- tools/win32/configure.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/win-dev.ps1 b/doc/win-dev.ps1 index 42a48d4f8..9c6c53ed1 100644 --- a/doc/win-dev.ps1 +++ b/doc/win-dev.ps1 @@ -14,7 +14,7 @@ function ThrowOnNativeFailure { $VsVersion = 2019 $MsvcVersion = '14.2' $BoostVersion = @(1, 71, 0) -$OpensslVersion = '1_1_1h' +$OpensslVersion = '1_1_1k' switch ($Env:BITS) { 32 { } diff --git a/tools/win32/configure.ps1 b/tools/win32/configure.ps1 index 0ac48fa02..a221ff5ab 100644 --- a/tools/win32/configure.ps1 +++ b/tools/win32/configure.ps1 @@ -30,7 +30,7 @@ if (-not (Test-Path env:CMAKE_GENERATOR_PLATFORM)) { } } if (-not (Test-Path env:OPENSSL_ROOT_DIR)) { - $env:OPENSSL_ROOT_DIR = "c:\local\OpenSSL_1_1_1h-Win${env:BITS}" + $env:OPENSSL_ROOT_DIR = "c:\local\OpenSSL_1_1_1k-Win${env:BITS}" } if (-not (Test-Path env:BOOST_ROOT)) { $env:BOOST_ROOT = "c:\local\boost_1_71_0-Win${env:BITS}" From 743af40114d2b00d883c9b03484fdcbe36c4eb40 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 19 May 2021 16:10:57 +0200 Subject: [PATCH 2/5] ScheduledDowntime: ignore not related Downtimes while creating Downtimes --- lib/icinga/scheduleddowntime.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index 41a727da2..2467ffce2 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -238,12 +238,14 @@ void ScheduledDowntime::CreateNextDowntime() double minEnd = 0; for (const Downtime::Ptr& downtime : GetCheckable()->GetDowntimes()) { + if (downtime->GetScheduledBy() != GetName()) + continue; + double end = downtime->GetEndTime(); if (end > minEnd) minEnd = end; - if (downtime->GetScheduledBy() != GetName() || - downtime->GetStartTime() < Utility::GetTime()) + if (downtime->GetStartTime() < Utility::GetTime()) continue; /* We've found a downtime that is owned by us and that hasn't started yet - we're done. */ From a262d189218ee599e0f8fa90a8f168e1553734b6 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Mon, 5 Oct 2020 15:12:42 +0200 Subject: [PATCH 3/5] Introduce Downtime#config_owner_hash refs #8309 --- lib/icinga/downtime.cpp | 6 ++++++ lib/icinga/downtime.ti | 1 + lib/icinga/scheduleddowntime.cpp | 20 ++++++++++++++++++++ lib/icinga/scheduleddowntime.hpp | 1 + 4 files changed, 28 insertions(+) diff --git a/lib/icinga/downtime.cpp b/lib/icinga/downtime.cpp index 9c618b786..668687aae 100644 --- a/lib/icinga/downtime.cpp +++ b/lib/icinga/downtime.cpp @@ -238,6 +238,12 @@ Downtime::Ptr Downtime::AddDowntime(const Checkable::Ptr& checkable, const Strin if (localZone) { attrs->Set("authoritative_zone", localZone->GetName()); } + + auto sd (ScheduledDowntime::GetByName(scheduledDowntime)); + + if (sd) { + attrs->Set("config_owner_hash", sd->HashDowntimeOptions()); + } } Host::Ptr host; diff --git a/lib/icinga/downtime.ti b/lib/icinga/downtime.ti index a55942fb0..fa02f2592 100644 --- a/lib/icinga/downtime.ti +++ b/lib/icinga/downtime.ti @@ -69,6 +69,7 @@ class Downtime : ConfigObject < DowntimeNameComposer [state] int legacy_id; [state] bool was_cancelled; [config] String config_owner; + [config] String config_owner_hash; [config] String authoritative_zone; }; diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index 2467ffce2..93b34a154 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -6,13 +6,17 @@ #include "icinga/downtime.hpp" #include "icinga/service.hpp" #include "base/timer.hpp" +#include "base/tlsutility.hpp" #include "base/configtype.hpp" #include "base/utility.hpp" #include "base/objectlock.hpp" +#include "base/object-packer.hpp" +#include "base/serializer.hpp" #include "base/convert.hpp" #include "base/logger.hpp" #include "base/exception.hpp" #include +#include using namespace icinga; @@ -333,6 +337,22 @@ void ScheduledDowntime::ValidateChildOptions(const Lazy& lvalue, const Va } } +static const std::set l_SDDowntimeOptions ({ + "author", "child_options", "comment", "duration", "fixed", "ranges", "vars" +}); + +String ScheduledDowntime::HashDowntimeOptions() +{ + Dictionary::Ptr allOpts = Serialize(this, FAConfig); + Dictionary::Ptr opts = new Dictionary(); + + for (auto& opt : l_SDDowntimeOptions) { + opts->Set(opt, allOpts->Get(opt)); + } + + return SHA256(PackObject(opts)); +} + bool ScheduledDowntime::AllConfigIsLoaded() { return m_AllConfigLoaded.load(); diff --git a/lib/icinga/scheduleddowntime.hpp b/lib/icinga/scheduleddowntime.hpp index 90e12d240..3c1a23d47 100644 --- a/lib/icinga/scheduleddowntime.hpp +++ b/lib/icinga/scheduleddowntime.hpp @@ -35,6 +35,7 @@ public: void ValidateRanges(const Lazy& lvalue, const ValidationUtils& utils) override; void ValidateChildOptions(const Lazy& lvalue, const ValidationUtils& utils) override; + String HashDowntimeOptions(); protected: void OnAllConfigLoaded() override; From ffa3872b28c022f6c859cdbf1b61137d62abb39d Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 19 May 2021 12:51:31 +0200 Subject: [PATCH 4/5] On ScheduledDowntime change: ignore downtimes created before change ... while creating new downtimes. refs #8309 --- lib/icinga/scheduleddowntime.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index 93b34a154..9b9b1e941 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -240,11 +240,16 @@ void ScheduledDowntime::CreateNextDowntime() } double minEnd = 0; + auto downtimeOptionsHash (HashDowntimeOptions()); for (const Downtime::Ptr& downtime : GetCheckable()->GetDowntimes()) { if (downtime->GetScheduledBy() != GetName()) continue; + auto configOwnerHash (downtime->GetConfigOwnerHash()); + if (!configOwnerHash.IsEmpty() && configOwnerHash != downtimeOptionsHash) + continue; + double end = downtime->GetEndTime(); if (end > minEnd) minEnd = end; From 084acbe028f76534a0c3ac1c404796cb46928932 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Fri, 2 Jul 2021 10:37:29 +0200 Subject: [PATCH 5/5] On ScheduledDowntime change: remove future downtimes created before change refs #8309 --- lib/icinga/scheduleddowntime.cpp | 27 +++++++++++++++++++++++++++ lib/icinga/scheduleddowntime.hpp | 1 + 2 files changed, 28 insertions(+) diff --git a/lib/icinga/scheduleddowntime.cpp b/lib/icinga/scheduleddowntime.cpp index 9b9b1e941..f01f03bdd 100644 --- a/lib/icinga/scheduleddowntime.cpp +++ b/lib/icinga/scheduleddowntime.cpp @@ -98,6 +98,15 @@ void ScheduledDowntime::TimerProc() Log(LogCritical, "ScheduledDowntime") << "Exception occurred during creation of next downtime for scheduled downtime '" << sd->GetName() << "': " << DiagnosticInformation(ex, false); + continue; + } + + try { + sd->RemoveObsoleteDowntimes(); + } catch (const std::exception& ex) { + Log(LogCritical, "ScheduledDowntime") + << "Exception occurred during removal of obsolete downtime for scheduled downtime '" + << sd->GetName() << "': " << DiagnosticInformation(ex, false); } } } @@ -301,6 +310,24 @@ void ScheduledDowntime::CreateNextDowntime() } } +void ScheduledDowntime::RemoveObsoleteDowntimes() +{ + auto name (GetName()); + auto downtimeOptionsHash (HashDowntimeOptions()); + + // Just to be sure start and removal don't happen at the same time + auto threshold (Utility::GetTime() + 5 * 60); + + for (const Downtime::Ptr& downtime : GetCheckable()->GetDowntimes()) { + if (downtime->GetScheduledBy() == name && downtime->GetStartTime() > threshold) { + auto configOwnerHash (downtime->GetConfigOwnerHash()); + + if (!configOwnerHash.IsEmpty() && configOwnerHash != downtimeOptionsHash) + Downtime::RemoveDowntime(downtime->GetName(), false, true); + } + } +} + void ScheduledDowntime::ValidateRanges(const Lazy& lvalue, const ValidationUtils& utils) { ObjectImpl::ValidateRanges(lvalue, utils); diff --git a/lib/icinga/scheduleddowntime.hpp b/lib/icinga/scheduleddowntime.hpp index 3c1a23d47..f8d8e0840 100644 --- a/lib/icinga/scheduleddowntime.hpp +++ b/lib/icinga/scheduleddowntime.hpp @@ -47,6 +47,7 @@ private: std::pair FindRunningSegment(double minEnd = 0); std::pair FindNextSegment(); void CreateNextDowntime(); + void RemoveObsoleteDowntimes(); static std::atomic m_AllConfigLoaded;