Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A resource invocation that throws an exception can cause endless loop. #21

Closed
alx9r opened this issue Nov 26, 2016 · 1 comment
Closed
Labels

Comments

@alx9r
Copy link
Owner

alx9r commented Nov 26, 2016

Currently the config instructions enumerable does not catch exceptions that invoking a resource might throw. This can lead to an endless loop.

Repro

Running this code causes an endless loop.

$document = {
    Get-DscResource TestStub | Import-DscResource

    TestStub a @{
        Key = 'a'
        ThrowOnSet = 'always'
    }
}

$instructions = ConfigInstructions Name $document
$instructions |
    Invoke-ConfigStep

The above code results in an endless loop.

Solution

Exceptions thrown by resources should be caught, the resource marked as "failed" (or maybe "ExceptionThrown"), and then the exception re-thrown. If the resource is marked with a new value like "ExceptionThrown", the state machines should also be altered to raise and handle 'AtExceptionThrown' events.

@alx9r alx9r added the Bug label Nov 26, 2016
@alx9r
Copy link
Owner Author

alx9r commented Dec 13, 2016

It seems like the .Invoke('Set') here should be wrapped in a try{} block.

@alx9r alx9r mentioned this issue Dec 25, 2016
@alx9r alx9r closed this as completed in b076183 Dec 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant