From 9c69c351a8aa91b9fe20b9704713dfe95674a90d Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 6 Jun 2024 14:39:45 +0200 Subject: [PATCH] Fixes Update-Icinga to print an error in case a component is not installed --- doc/100-General/10-Changelog.md | 1 + lib/core/repository/Update-Icinga.psm1 | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 1cc3595..c605382 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -13,6 +13,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic ### Bugfixes +* [#729](https://github.com/Icinga/icinga-powershell-framework/issues/729) Fixes `Update-Icinga` to print an error in case a component is not installed, instead of silently continue * [#734](https://github.com/Icinga/icinga-powershell-framework/issues/734) Fixes a scenario on which a JEA service could become orphaned while manually stopping the Icinga for Windows service, without gracefully shutting down JEA ### Enhancements diff --git a/lib/core/repository/Update-Icinga.psm1 b/lib/core/repository/Update-Icinga.psm1 index 1b1e2fc..cc73fdb 100644 --- a/lib/core/repository/Update-Icinga.psm1 +++ b/lib/core/repository/Update-Icinga.psm1 @@ -16,6 +16,7 @@ function Update-Icinga() $CurrentInstallation = Get-IcingaInstallation -Release:$Release -Snapshot:$Snapshot; [bool]$UpdateJEA = $FALSE; [array]$ComponentsList = @(); + [bool]$IsInstalled = $FALSE; # 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 @@ -44,6 +45,8 @@ function Update-Icinga() continue; } + $IsInstalled = $TRUE; + $NewVersion = $Component.LatestVersion; if ([string]::IsNullOrEmpty($Version) -eq $FALSE) { @@ -76,6 +79,10 @@ function Update-Icinga() Install-IcingaComponent -Name $entry -Version $NewVersion -Release:$Release -Snapshot:$Snapshot -Confirm:$Confirm -Force:$Force -KeepRepoErrors; } + if ($IsInstalled -eq $FALSE) { + Write-IcingaConsoleError 'Failed to update the component "{0}", as it is not installed' -Objects $Name; + } + # Update JEA profile if JEA is enabled once the update is complete if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE -And $UpdateJEA) { Update-IcingaJEAProfile;