- Notifications
You must be signed in to change notification settings - Fork909
Commit5f516ed
authored
feat: improve coder connect tunnel handling on reconnect (#17598)
Closescoder/internal#563The [Coder Connecttunnel](https://github.com/coder/coder/blob/main/vpn/tunnel.go) receivesworkspace state from the Coder server over a [dRPCstream.](https://github.com/coder/coder/blob/114ba4593b2a82dfd41cdcb7fd6eb70d866e7b86/tailnet/controllers.go#L1029)When first connecting to this stream, the current state of the user'sworkspaces is received, with subsequent messages being diffs on top ofthat state.However, if the client disconnects from this stream, such as when theuser's device is suspended, and then reconnects later, no mechanismexists for the tunnel to differentiate that message containing theentire initial state from another diff, and so that state is incorrectlyapplied as a diff.In practice:- Tunnel connects, receives a workspace update containing all theexisting workspaces & agents.- Tunnel loses connection, but isn't completely stopped.- All the user's workspaces are restarted, producing a new set ofagents.- Tunnel regains connection, and receives a workspace update containingall the existing workspaces & agents.- This initial update is incorrectly applied as a diff, with theTunnel's state containing both the old & new agents.This PR introduces a solution in which tunnelUpdater, when created,sends a FreshState flag with the WorkspaceUpdate type. This flag ishandled in the vpn tunnel in the following fashion:- Preserve existing Agents- Remove current Agents in the tunnel that are not present in theWorkspaceUpdate- Remove unreferenced Workspaces1 parentebad5c3 commit5f516ed
File tree
4 files changed
+498
-16
lines changed- tailnet
- vpn
4 files changed
+498
-16
lines changedLines changed: 30 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
897 | 897 |
| |
898 | 898 |
| |
899 | 899 |
| |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
900 | 915 |
| |
901 | 916 |
| |
902 | 917 |
| |
| |||
1049 | 1064 |
| |
1050 | 1065 |
| |
1051 | 1066 |
| |
| 1067 | + | |
1052 | 1068 |
| |
1053 | 1069 |
| |
1054 | 1070 |
| |
| |||
1061 | 1077 |
| |
1062 | 1078 |
| |
1063 | 1079 |
| |
| 1080 | + | |
1064 | 1081 |
| |
1065 |
| - | |
| 1082 | + | |
| 1083 | + | |
1066 | 1084 |
| |
1067 | 1085 |
| |
1068 | 1086 |
| |
| |||
1083 | 1101 |
| |
1084 | 1102 |
| |
1085 | 1103 |
| |
| 1104 | + | |
1086 | 1105 |
| |
1087 | 1106 |
| |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
| 1112 | + | |
| 1113 | + | |
1088 | 1114 |
| |
1089 | 1115 |
| |
1090 | 1116 |
| |
1091 | 1117 |
| |
1092 | 1118 |
| |
1093 | 1119 |
| |
| 1120 | + | |
1094 | 1121 |
| |
1095 | 1122 |
| |
1096 | 1123 |
| |
| |||
1115 | 1142 |
| |
1116 | 1143 |
| |
1117 | 1144 |
| |
1118 |
| - | |
| 1145 | + | |
1119 | 1146 |
| |
1120 | 1147 |
| |
1121 | 1148 |
| |
| |||
1124 | 1151 |
| |
1125 | 1152 |
| |
1126 | 1153 |
| |
| 1154 | + | |
1127 | 1155 |
| |
1128 | 1156 |
| |
1129 | 1157 |
| |
|
Lines changed: 8 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1611 | 1611 |
| |
1612 | 1612 |
| |
1613 | 1613 |
| |
| 1614 | + | |
1614 | 1615 |
| |
1615 | 1616 |
| |
1616 | 1617 |
| |
| |||
1626 | 1627 |
| |
1627 | 1628 |
| |
1628 | 1629 |
| |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
1629 | 1633 |
| |
1630 | 1634 |
| |
1631 | 1635 |
| |
| |||
1692 | 1696 |
| |
1693 | 1697 |
| |
1694 | 1698 |
| |
| 1699 | + | |
1695 | 1700 |
| |
1696 | 1701 |
| |
1697 | 1702 |
| |
1698 | 1703 |
| |
1699 | 1704 |
| |
1700 |
| - | |
1701 | 1705 |
| |
1702 | 1706 |
| |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
1703 | 1710 |
| |
1704 | 1711 |
| |
1705 | 1712 |
| |
|
Lines changed: 64 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
| 91 | + | |
91 | 92 |
| |
92 | 93 |
| |
93 | 94 |
| |
| |||
347 | 348 |
| |
348 | 349 |
| |
349 | 350 |
| |
350 |
| - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
351 | 354 |
| |
352 | 355 |
| |
353 | 356 |
| |
| |||
397 | 400 |
| |
398 | 401 |
| |
399 | 402 |
| |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
400 | 408 |
| |
401 | 409 |
| |
402 | 410 |
| |
403 | 411 |
| |
404 | 412 |
| |
405 | 413 |
| |
406 | 414 |
| |
407 |
| - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
408 | 429 |
| |
409 | 430 |
| |
410 | 431 |
| |
| |||
413 | 434 |
| |
414 | 435 |
| |
415 | 436 |
| |
| 437 | + | |
416 | 438 |
| |
417 | 439 |
| |
418 | 440 |
| |
| |||
472 | 494 |
| |
473 | 495 |
| |
474 | 496 |
| |
475 |
| - | |
476 |
| - | |
477 |
| - | |
478 |
| - | |
479 |
| - | |
480 |
| - | |
481 |
| - | |
482 |
| - | |
483 |
| - | |
484 |
| - | |
485 |
| - | |
486 | 497 |
| |
487 | 498 |
| |
488 | 499 |
| |
| |||
552 | 563 |
| |
553 | 564 |
| |
554 | 565 |
| |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
555 | 606 |
| |
556 | 607 |
| |
557 | 608 |
| |
|
0 commit comments
Comments
(0)