Commit 124e5a3
committed
Handle error events in HCS notifications.
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 a `processAsyncHcsResult`
in the appropriate system or process call in `"internal.hcs"`, or via
`waitForNotification` in `waitBackground`).
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 the
`notificationWatcher` callback into the appropriate `hcsResult` 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 by `hcsResult` errors.
Since `ErrorEvent`s are always converted to strings in the context of
serializing several of them into a string, 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.
Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>1 parent 9e4e729 commit 124e5a3
2 files changed
+155
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
| 15 | + | |
11 | 16 | | |
12 | 17 | | |
13 | | - | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
139 | 152 | | |
140 | 153 | | |
141 | 154 | | |
142 | | - | |
| 155 | + | |
143 | 156 | | |
144 | 157 | | |
145 | | - | |
| 158 | + | |
| 159 | + | |
146 | 160 | | |
147 | 161 | | |
148 | 162 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
155 | 166 | | |
156 | | - | |
| 167 | + | |
157 | 168 | | |
158 | | - | |
| 169 | + | |
159 | 170 | | |
160 | 171 | | |
161 | 172 | | |
162 | 173 | | |
163 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
102 | | - | |
103 | | - | |
104 | 106 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | | - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
113 | 124 | | |
114 | | - | |
| 125 | + | |
115 | 126 | | |
116 | 127 | | |
117 | | - | |
| 128 | + | |
118 | 129 | | |
119 | 130 | | |
120 | | - | |
| 131 | + | |
121 | 132 | | |
122 | 133 | | |
123 | | - | |
| 134 | + | |
124 | 135 | | |
125 | 136 | | |
126 | | - | |
| 137 | + | |
127 | 138 | | |
128 | | - | |
129 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
130 | 147 | | |
131 | 148 | | |
132 | 149 | | |
133 | 150 | | |
134 | 151 | | |
135 | 152 | | |
136 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
137 | 157 | | |
138 | 158 | | |
139 | 159 | | |
140 | 160 | | |
141 | 161 | | |
142 | 162 | | |
143 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
144 | 185 | | |
145 | 186 | | |
146 | 187 | | |
| |||
150 | 191 | | |
151 | 192 | | |
152 | 193 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 194 | + | |
158 | 195 | | |
159 | 196 | | |
160 | 197 | | |
| |||
194 | 231 | | |
195 | 232 | | |
196 | 233 | | |
197 | | - | |
198 | | - | |
199 | | - | |
200 | | - | |
201 | | - | |
| 234 | + | |
202 | 235 | | |
203 | 236 | | |
204 | 237 | | |
| |||
208 | 241 | | |
209 | 242 | | |
210 | 243 | | |
| 244 | + | |
211 | 245 | | |
212 | 246 | | |
213 | 247 | | |
| |||
228 | 262 | | |
229 | 263 | | |
230 | 264 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
| 265 | + | |
236 | 266 | | |
237 | 267 | | |
238 | 268 | | |
| |||
241 | 271 | | |
242 | 272 | | |
243 | 273 | | |
| 274 | + | |
| 275 | + | |
244 | 276 | | |
245 | 277 | | |
246 | 278 | | |
| |||
252 | 284 | | |
253 | 285 | | |
254 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
255 | 315 | | |
256 | 316 | | |
257 | 317 | | |
| |||
0 commit comments