Merge pull request #214 from Icinga:fix/race_condition_exception_for_plugin_execution

Fix wrong plugin not installed unknown checkresult

Unknown checks for the plugin handler were called to soon, as the minimal configuration does not load old check commands for the plugins.
In addition API checks did not throw an unknown and were not catched properly
This commit is contained in:
Lord Hepipud 2021-03-01 12:08:59 +01:00 committed by GitHub
commit 2ae5aff7cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View file

@ -34,6 +34,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#208](https://github.com/Icinga/icinga-powershell-framework/pull/208) Fixes `Convert-IcingaPluginThresholds` which sometimes did not return proper numeric usable values for our internal functions, causing issues on plugin calls. In addition the function now also supports the handling for % units. * [#208](https://github.com/Icinga/icinga-powershell-framework/pull/208) Fixes `Convert-IcingaPluginThresholds` which sometimes did not return proper numeric usable values for our internal functions, causing issues on plugin calls. In addition the function now also supports the handling for % units.
* [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed possible crash on `Get-IcingaAgentFeatures` if PowerShell is not running as administrator and therefor the command `icinga2 feature list` can not be processed * [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed possible crash on `Get-IcingaAgentFeatures` if PowerShell is not running as administrator and therefor the command `icinga2 feature list` can not be processed
* [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed `ConvertTo-IcingaSecureString` to return `$null` for empty strings instead of throwing an exception * [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed `ConvertTo-IcingaSecureString` to return `$null` for empty strings instead of throwing an exception
* [#214](https://github.com/Icinga/icinga-powershell-framework/pull/214) Fixes wrong `[Unknown] PluginNotInstalled` exception because of new plugin configuration and wrong checking against APi result in case feature is enabled
### Experimental ### Experimental

View file

@ -101,12 +101,17 @@ function Invoke-IcingaInternalServiceCall()
$IcingaCR = ''; $IcingaCR = '';
# In case we didn't receive a check result, fallback to local execution # In case we didn't receive a check result, fallback to local execution
if ($null -eq $IcingaResult.$Command.checkresult) { if ([string]::IsNullOrEmpty($IcingaResult.$Command.checkresult)) {
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments; Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments;
return; return;
} }
$IcingaCR = ($IcingaResult.$Command.checkresult.Replace("`r`n", "`n")); if ([string]::IsNullOrEmpty($IcingaResult.$Command.exitcode)) {
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments;
return;
}
$IcingaCR = ($IcingaResult.$Command.checkresult.Replace("`r`n", "`n"));
if ($IcingaResult.$Command.perfdata.Count -ne 0) { if ($IcingaResult.$Command.perfdata.Count -ne 0) {
$IcingaCR += ' | '; $IcingaCR += ' | ';

View file

@ -4,8 +4,6 @@ function Exit-IcingaExecutePlugin()
[string]$Command = '' [string]$Command = ''
); );
Exit-IcingaPluginNotInstalled -Command $Command;
Invoke-IcingaInternalServiceCall -Command $Command -Arguments $args; Invoke-IcingaInternalServiceCall -Command $Command -Arguments $args;
try { try {
@ -14,6 +12,8 @@ function Exit-IcingaExecutePlugin()
Use-Icinga; Use-Icinga;
} }
Exit-IcingaPluginNotInstalled -Command $Command;
exit (& $Command @args); exit (& $Command @args);
} catch { } catch {
$ExMsg = $_.Exception.Message; $ExMsg = $_.Exception.Message;