Commit d895118
committed
runtime/v2/runc: fix leaking socket path
When runC shimv2 starts, the StartShim interface will re-exec itself as
long-running process, which will read the `address` during initializing.
```happycase
Process
containerd-shim-runc-v1/v2 start containerd-shim-runc-v1/v2
initializing socket
reexec containerd-shim-runc-v1/v2
write address into file
initializing
read address
write back to containerd daemon
serving
...
remove address in Shutdown call
```
However, there is no synchronization after reexec. Then the data race is
like:
```leaking-case
Process
containerd-shim-runc-v1/v2 start containerd-shim-runc-v1/v2
initializing socket
reexec containerd-shim-runc-v1/v2
initializing
read address
write address into file
write back to containerd daemon
serving
...
fail to remove address
because of empty address
```
The `address` should be writen into file first before reexec.
And if shutdown the whole service before cleanup temporary
resource (like socket file), the Shutdown caller will receive `ttrpc: closed`
sometime, which depends on go runtime scheduler. Then it also causes leaking
socket files.
Since the shimV2-Delete binary API must be called to cleanup shim temporary
resource and shimV2-runC-v1 doesn't support grouping multi containers in one,
it is safe to remove the socket file in the binary call for shimV2-runC-v1.
But for the shimV2-runC-v2 shim, we still cleanup socket in Shutdown.
Hopefully we can find a way to cleanup socket in shimV2-Delete binary
call.
Fix: #5173
Signed-off-by: Wei Fu <[email protected]>1 parent d8208e2 commit d895118
3 files changed
Lines changed: 34 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| |||
174 | 179 | | |
175 | 180 | | |
176 | 181 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
209 | 211 | | |
210 | 212 | | |
211 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
212 | 220 | | |
213 | 221 | | |
214 | 222 | | |
| |||
562 | 570 | | |
563 | 571 | | |
564 | 572 | | |
| 573 | + | |
| 574 | + | |
565 | 575 | | |
566 | 576 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | 577 | | |
571 | 578 | | |
572 | 579 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
223 | 229 | | |
224 | 230 | | |
225 | 231 | | |
| |||
238 | 244 | | |
239 | 245 | | |
240 | 246 | | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| |||
290 | 293 | | |
291 | 294 | | |
292 | 295 | | |
| 296 | + | |
293 | 297 | | |
294 | 298 | | |
295 | 299 | | |
| |||
668 | 672 | | |
669 | 673 | | |
670 | 674 | | |
671 | | - | |
672 | | - | |
673 | 675 | | |
674 | 676 | | |
675 | 677 | | |
676 | 678 | | |
| 679 | + | |
677 | 680 | | |
678 | 681 | | |
679 | 682 | | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
680 | 688 | | |
681 | 689 | | |
682 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
242 | 249 | | |
243 | 250 | | |
244 | 251 | | |
| |||
299 | 306 | | |
300 | 307 | | |
301 | 308 | | |
| 309 | + | |
302 | 310 | | |
303 | 311 | | |
304 | 312 | | |
305 | 313 | | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
| |||
0 commit comments