Handle error events in HCS notifications. #2526
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The shim parses the JSON result document and handle the error events (via
processHcsResult
) returned by HCS calls (e.g.,vmcompute.HcsCreateComputeSystem
), but ignores the JSON payload for notifications (which are either received from aprocessAsyncHcsResult
in the appropriate system or process call in"internal.hcs"
, or viawaitForNotification
inwaitBackground
).This leads to ambiguous failure errors (e.g.,
"The data is invalid."
) that require ETW traces to track down the appropriate HCS logs, when the error events could have provided enough context to identify the issue.Parse the
notificationData
JSON payload provided by HCS to thenotificationWatcher
callback into the appropriatehcsResult
struct.Validate that the JSON data matches the notification HResult.
Create a new error type (
hcsResult
) to handle both the error and events.Since notification results are always subsequently passed to either
make(System|Process)Error
, update those functions to handle the events provided byhcsResult
errors.Since
ErrorEvent
s are always converted to strings in the context of concatenating several of them together, add an(*ErrorEvent).writeTo(*string.Builder)
function to provide more efficient error string generation for(HCS|System|Process)Error
s. Additionally, consolidate the joining and formatting of error events for those error types.