Skip to content

Commit 97bd444

Browse files
authored
Merge pull request #441 from Icinga:fix/exception_on_framework_loading
Fix: Exception on loading by missing environment Fixes an exception while loading the Framework, caused by a race condition for missing environment variables which are accessed by some plugins before the Framework is loaded properly.
2 parents db4d86e + 7faa516 commit 97bd444

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
2828
* [#421](https://github.com/Icinga/icinga-powershell-framework/issues/421) Fixes experimental state of `API Check` feature by removing that term and removing the requirement to install `icinga-powershell-restapi` and `icinga-powershell-apichecks`
2929
* [#436](https://github.com/Icinga/icinga-powershell-framework/pull/436) Fixes a lookup error for existing plugin documentation files, which caused files not being generated properly in case a similar name was already present on the system
3030
* [#439](https://github.com/Icinga/icinga-powershell-framework/pull/439) Moves PerformanceCounter to private space from previous public, which caused some problems
31+
* [#441](https://github.com/Icinga/icinga-powershell-framework/pull/441) Fixes an exception while loading the Framework, caused by a race condition for missing environment variables which are accessed by some plugins before the Framework is loaded properly
3132

3233
### Enhancements
3334

icinga-powershell-framework.psm1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ function Use-Icinga()
3131
}
3232

3333
Disable-IcingaProgressPreference;
34-
New-IcingaEnvironmentVariable;
3534

3635
if ($Minimal) {
3736
$Global:Icinga.Protected.Minimal = $TRUE;
@@ -284,5 +283,11 @@ function Start-IcingaShellAsUser()
284283
);
285284
}
286285

286+
# Always ensure our environment variables are set to reduce possibles errors
287+
# in case we call functions accessing them
288+
if (Get-Command -Name 'New-IcingaEnvironmentVariable' -ErrorAction SilentlyContinue) {
289+
New-IcingaEnvironmentVariable;
290+
}
291+
287292
Set-Alias icinga Invoke-IcingaCommand -Description "Execute Icinga Framework commands in a new PowerShell instance for testing or quick access to data";
288293
Export-ModuleMember -Alias * -Function * -Variable *;

0 commit comments

Comments
 (0)