classifyCoordinatorRPCExit determines the DisconnectReason and DisconnectInitiator for a coordinator-style RPC (the coordination RPC and the DERP map subscriber RPC) that has just returned. A canceled local context means the agent itself is shutting down. A non-nil return error without context cance
(ctx context.Context, retErr error)
| 1890 | // return error without context cancellation means the stream broke |
| 1891 | // unexpectedly. |
| 1892 | func classifyCoordinatorRPCExit(ctx context.Context, retErr error) (codersdk.DisconnectReason, codersdk.DisconnectInitiator) { |
| 1893 | localShutdown := ctx.Err() != nil |
| 1894 | switch { |
| 1895 | case localShutdown: |
| 1896 | return codersdk.DisconnectReasonServerShutdown, codersdk.DisconnectInitiatorAgent |
| 1897 | case retErr == nil: |
| 1898 | return codersdk.DisconnectReasonGraceful, codersdk.DisconnectInitiatorServer |
| 1899 | default: |
| 1900 | return codersdk.DisconnectReasonNetworkError, codersdk.DisconnectInitiatorNetwork |
| 1901 | } |
| 1902 | } |
| 1903 | |
| 1904 | // runCoordinator runs a coordinator and returns whether a reconnect |
| 1905 | // should occur. |