Skip to content

Commit 2ae5aff

Browse files
authored
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
2 parents ed43260 + e7c341e commit 2ae5aff

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

doc/31-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
3434
* [#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.
3535
* [#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
3636
* [#213](https://github.com/Icinga/icinga-powershell-framework/pull/213) Fixed `ConvertTo-IcingaSecureString` to return `$null` for empty strings instead of throwing an exception
37+
* [#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
3738

3839
### Experimental
3940

lib/core/framework/Invoke-IcingaInternalServiceCall.psm1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,17 @@ function Invoke-IcingaInternalServiceCall()
101101
$IcingaCR = '';
102102

103103
# In case we didn't receive a check result, fallback to local execution
104-
if ($null -eq $IcingaResult.$Command.checkresult) {
104+
if ([string]::IsNullOrEmpty($IcingaResult.$Command.checkresult)) {
105105
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments;
106106
return;
107107
}
108108

109-
$IcingaCR = ($IcingaResult.$Command.checkresult.Replace("`r`n", "`n"));
109+
if ([string]::IsNullOrEmpty($IcingaResult.$Command.exitcode)) {
110+
Write-IcingaEventMessage -Namespace 'Framework' -EventId 1553 -Objects 'The check result for the executed command was empty', $Command, $DebugArguments;
111+
return;
112+
}
113+
114+
$IcingaCR = ($IcingaResult.$Command.checkresult.Replace("`r`n", "`n"));
110115

111116
if ($IcingaResult.$Command.perfdata.Count -ne 0) {
112117
$IcingaCR += ' | ';

lib/icinga/plugin/Exit-IcingaExecutePlugin.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ function Exit-IcingaExecutePlugin()
44
[string]$Command = ''
55
);
66

7-
Exit-IcingaPluginNotInstalled -Command $Command;
8-
97
Invoke-IcingaInternalServiceCall -Command $Command -Arguments $args;
108

119
try {
@@ -14,6 +12,8 @@ function Exit-IcingaExecutePlugin()
1412
Use-Icinga;
1513
}
1614

15+
Exit-IcingaPluginNotInstalled -Command $Command;
16+
1717
exit (& $Command @args);
1818
} catch {
1919
$ExMsg = $_.Exception.Message;

0 commit comments

Comments
 (0)