From b280ccffc4421d7777fcf117d1256b74a1114285 Mon Sep 17 00:00:00 2001 From: LordHepipud Date: Mon, 1 Apr 2024 16:03:37 +0200 Subject: [PATCH] Fixes update order for components to always update the framework first --- doc/100-General/10-Changelog.md | 1 + lib/core/repository/Update-Icinga.psm1 | 25 +++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index d076280a..2b786a2d 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#672](https://github.com/Icinga/icinga-powershell-framework/pull/issues) Fixes Icinga for Windows REST-Api to fully read client data, even when they client is sending the packets on a very slow basis, preventing the API trying to process an incomplete request * [#707](https://github.com/Icinga/icinga-powershell-framework/pull/707) Fixes size of the `Icinga for Windows` eventlog by setting it to `20MiB`, allowing to store more events before they are overwritten +* [#708](https://github.com/Icinga/icinga-powershell-framework/pull/708) Fixes the order for updating components with `Update-Icinga`, to ensure the `framework` is always updated first before all other components * [#710](https://github.com/Icinga/icinga-powershell-framework/pull/710) Fixes various console errors while running Icinga for Windows outside of an administrative shell * [#713](https://github.com/Icinga/icinga-powershell-framework/pull/713) Fixes Icinga for Windows REST-Api which fails during certificate auth handling while running as `NT Authority\NetworkService` * [#714](https://github.com/Icinga/icinga-powershell-framework/pull/714) Fixes missing service environment information during initial setup of Icinga for Windows v1.12 on some systems diff --git a/lib/core/repository/Update-Icinga.psm1 b/lib/core/repository/Update-Icinga.psm1 index 42632897..1cb881ef 100644 --- a/lib/core/repository/Update-Icinga.psm1 +++ b/lib/core/repository/Update-Icinga.psm1 @@ -13,10 +13,31 @@ function Update-Icinga() $Release = $TRUE; } - $CurrentInstallation = Get-IcingaInstallation -Release:$Release -Snapshot:$Snapshot; - [bool]$UpdateJEA = $FALSE; + $CurrentInstallation = Get-IcingaInstallation -Release:$Release -Snapshot:$Snapshot; + [bool]$UpdateJEA = $FALSE; + [array]$ComponentsList = @(); + # We need to make sure that the framework is always installed first as component + # to prevent possible race-conditions during update, in case we update plugins + # before the framework. For plugins this applies as well, as other components + # could use them as depdency + if ($CurrentInstallation.ContainsKey('framework')) { + $ComponentsList += 'framework'; + } + if ($CurrentInstallation.ContainsKey('plugins')) { + $ComponentsList += 'plugins'; + } + + # Add all other components, but skip the framework in this case foreach ($entry in $CurrentInstallation.Keys) { + if ($entry -eq 'framework' -Or $entry -eq 'plugins') { + continue; + } + $ComponentsList += $entry; + } + + # Now process with your installation + foreach ($entry in $ComponentsList) { $Component = $CurrentInstallation[$entry]; if ([string]::IsNullOrEmpty($Name) -eq $FALSE -And $Name -ne $entry) {