Merge pull request #456 from Icinga:fix/jea_service_error_does_not_reset

Fix: JEA service error count not resetting itself

While running the Icinga for Windows service in JEA context, it can happen that the corresponding WinRM service is restarted or terminated. The service daemon will keep an eye on that and restart the JEA session up to 5 times, before terminating the service and printing an error.

This fix will not add a grace period, which will reset the failure counter in case the service was running for more than 3 minutes. Which is more then enough runtime to not asume a faulty service behavior.
This commit is contained in:
Lord Hepipud 2022-01-29 00:28:35 +01:00 committed by GitHub
commit d8e87b9272
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -36,6 +36,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#451](https://github.com/Icinga/icinga-powershell-framework/pull/451) Fixes PowerShell being unable to enter JEA context if only the Framework is installed and removes the `|` from plugin output, in case a JEA error is thrown that check commands are not present * [#451](https://github.com/Icinga/icinga-powershell-framework/pull/451) Fixes PowerShell being unable to enter JEA context if only the Framework is installed and removes the `|` from plugin output, in case a JEA error is thrown that check commands are not present
* [#452](https://github.com/Icinga/icinga-powershell-framework/pull/452) Fixes unhandled `true` output on the console while running the installer * [#452](https://github.com/Icinga/icinga-powershell-framework/pull/452) Fixes unhandled `true` output on the console while running the installer
* [#454](https://github.com/Icinga/icinga-powershell-framework/pull/454) Fixes JEA catalog compiler and background daemon execution in JEA context * [#454](https://github.com/Icinga/icinga-powershell-framework/pull/454) Fixes JEA catalog compiler and background daemon execution in JEA context
* [#456](https://github.com/Icinga/icinga-powershell-framework/pull/456) Fixes JEA service error count not resetting itself after a certain amount of time without errors
### Enhancements ### Enhancements

View file

@ -73,6 +73,7 @@ function Start-IcingaForWindowsDaemon()
if ($RunAsService) { if ($RunAsService) {
[int]$JeaRestartCounter = 1; [int]$JeaRestartCounter = 1;
$FailureTime = $null;
while ($TRUE) { while ($TRUE) {
if ([string]::IsNullOrEmpty($JeaProfile) -eq $FALSE) { if ([string]::IsNullOrEmpty($JeaProfile) -eq $FALSE) {
if ([string]::IsNullOrEmpty($JeaPid)) { if ([string]::IsNullOrEmpty($JeaPid)) {
@ -86,14 +87,22 @@ function Start-IcingaForWindowsDaemon()
} }
Write-IcingaFileSecure -File $JeaPidFile -Value ''; Write-IcingaFileSecure -File $JeaPidFile -Value '';
$FailureTime = [DateTime]::Now;
Write-IcingaEventMessage -EventId 1505 -Namespace Framework -Objects ([string]::Format('{0}/5', $JeaRestartCounter)); Write-IcingaEventMessage -EventId 1505 -Namespace Framework -Objects ([string]::Format('{0}/5', $JeaRestartCounter));
Start-IcingaForWindowsDaemon -RunAsService:$RunAsService -JEAContext:$JEAContext -JEARestart; Start-IcingaForWindowsDaemon -RunAsService:$RunAsService -JEAContext:$JEAContext -JEARestart;
if (([DateTime]::Now - $FailureTime).TotalSeconds -lt 180) {
$JeaRestartCounter += 1; $JeaRestartCounter += 1;
} else {
$JeaRestartCounter = 1;
}
$JeaPid = ''; $JeaPid = '';
} }
Start-Sleep -Seconds 5; Start-Sleep -Seconds 5;
$JeaAliveCounter += 1;
continue; continue;
} }
Start-Sleep -Seconds 100; Start-Sleep -Seconds 100;