fix: add timeout to listening ports request (#11935)

This can potentially hang for 15m if the agent is unreachable.
This commit is contained in:
Colin Adler
2024-01-30 13:53:52 -06:00
committed by GitHub
parent 7f1c808ff9
commit 27f3b7a814
+5
View File
@@ -722,6 +722,11 @@ func (api *API) workspaceAgentListeningPorts(rw http.ResponseWriter, r *http.Req
ctx := r.Context()
workspaceAgent := httpmw.WorkspaceAgentParam(r)
// If the agent is unreachable, the request will hang. Assume that if we
// don't get a response after 30s that the agent is unreachable.
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
apiAgent, err := db2sdk.WorkspaceAgent(
api.DERPMap(), *api.TailnetCoordinator.Load(), workspaceAgent, nil, nil, nil, api.AgentInactiveDisconnectTimeout,
api.DeploymentValues.AgentFallbackTroubleshootingURL.String(),