Merge pull request #590 from Icinga:fix/background_service_registration_not_working

Fix: Background service registration

Fixes background service registration caused by migration task for v1.10.0 being executed even when no services were defined before
This commit is contained in:
Lord Hepipud 2022-10-18 14:44:56 +02:00 committed by GitHub
commit 9f91290e23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 11 deletions

View file

@ -7,6 +7,14 @@ documentation before upgrading to a new release.
Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-framework/milestones?state=closed).
## 1.10.1 (2022-27-10)
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/27?closed=1)
### Bugfixes
* [#582](https://github.com/Icinga/icinga-powershell-framework/issues/582) Fixes background service registration caused by migration task for v1.10.0 being executed even when no services were defined before
## 1.10.0 (2022-08-30)
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/23?closed=1)

View file

@ -52,28 +52,41 @@ function Invoke-IcingaForWindowsMigration()
# Convert the time intervals for the background daemon services from the previous index handling
# 1, 3, 5, 15 as example to 1m, 3m, 5m, 15m
$BackgroundServices = Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices';
[hashtable]$Output = @{ };
foreach ($service in $BackgroundServices.PSObject.Properties) {
[array]$ConvertedTimeIndex = @();
# Only run this migration in case background services are defined
if ($null -ne $BackgroundServices) {
foreach ($service in $BackgroundServices.PSObject.Properties) {
[array]$ConvertedTimeIndex = @();
foreach ($interval in $service.Value.TimeIndexes) {
if (Test-Numeric $interval) {
$ConvertedTimeIndex += [string]::Format('{0}m', $interval);
} else {
$ConvertedTimeIndex = $interval;
foreach ($interval in $service.Value.TimeIndexes) {
if (Test-Numeric $interval) {
$ConvertedTimeIndex += [string]::Format('{0}m', $interval);
} else {
$ConvertedTimeIndex = $interval;
}
}
$service.Value.TimeIndexes = $ConvertedTimeIndex;
}
$service.Value.TimeIndexes = $ConvertedTimeIndex;
Set-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices' -Value $BackgroundServices;
}
Set-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices' -Value $BackgroundServices;
Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.10.0');
if ($ServiceStatus -eq 'Running') {
Restart-IcingaWindowsService -Service 'icingapowershell';
}
}
if (Test-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.10.1')) {
Write-IcingaConsoleNotice 'Applying pending migrations required for Icinga for Windows v1.10.1';
# Fix Icinga for Windows v1.10.0 broken background service registration
if ($null -eq (Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices')) {
Remove-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices';
}
Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.10.1');
}
}