Fixes background service registration

This commit is contained in:
Lord Hepipud 2022-10-18 12:21:05 +02:00
parent 19e422e7ac
commit d8f2a9ab55
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). 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) ## 1.10.0 (2022-08-30)
[Issue and PRs](https://github.com/Icinga/icinga-powershell-framework/milestone/23?closed=1) [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 # 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 # 1, 3, 5, 15 as example to 1m, 3m, 5m, 15m
$BackgroundServices = Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices'; $BackgroundServices = Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices';
[hashtable]$Output = @{ };
foreach ($service in $BackgroundServices.PSObject.Properties) { # Only run this migration in case background services are defined
[array]$ConvertedTimeIndex = @(); if ($null -ne $BackgroundServices) {
foreach ($service in $BackgroundServices.PSObject.Properties) {
[array]$ConvertedTimeIndex = @();
foreach ($interval in $service.Value.TimeIndexes) { foreach ($interval in $service.Value.TimeIndexes) {
if (Test-Numeric $interval) { if (Test-Numeric $interval) {
$ConvertedTimeIndex += [string]::Format('{0}m', $interval); $ConvertedTimeIndex += [string]::Format('{0}m', $interval);
} else { } else {
$ConvertedTimeIndex = $interval; $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'); Set-IcingaForWindowsMigration -MigrationVersion (New-IcingaVersionObject -Version '1.10.0');
if ($ServiceStatus -eq 'Running') { if ($ServiceStatus -eq 'Running') {
Restart-IcingaWindowsService -Service 'icingapowershell'; 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');
}
} }