From 9dee6b40c3455fc5183abef9c1f11fbd64b2e664 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Mon, 8 May 2023 16:04:19 -0500 Subject: [PATCH 1/3] chore: Drop application host call, default to regions for info Regions info provides the same information. So remove 1 api call --- coderd/apidoc/docs.go | 1 + coderd/apidoc/swagger.json | 1 + coderd/workspaceapps.go | 1 + site/src/contexts/ProxyContext.tsx | 28 +++++----------------------- 4 files changed, 8 insertions(+), 23 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 2ad130318dcbb..ee9e6db267da3 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -149,6 +149,7 @@ const docTemplate = `{ ], "summary": "Get applications host", "operationId": "get-applications-host", + "deprecated": true, "responses": { "200": { "description": "OK", diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index e2a593c1a415c..40801470b3a95 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -121,6 +121,7 @@ "tags": ["Applications"], "summary": "Get applications host", "operationId": "get-applications-host", + "deprecated": true, "responses": { "200": { "description": "OK", diff --git a/coderd/workspaceapps.go b/coderd/workspaceapps.go index cec40eed5650d..1f1224e028d7a 100644 --- a/coderd/workspaceapps.go +++ b/coderd/workspaceapps.go @@ -27,6 +27,7 @@ import ( // @Tags Applications // @Success 200 {object} codersdk.AppHostResponse // @Router /applications/host [get] +// @Deprecated use api/v2/regions and see the primary proxy. func (api *API) appHost(rw http.ResponseWriter, r *http.Request) { host := api.AppHostname if host != "" && api.AccessURL.Port() != "" { diff --git a/site/src/contexts/ProxyContext.tsx b/site/src/contexts/ProxyContext.tsx index eef89b31ef239..8d65c9622bc12 100644 --- a/site/src/contexts/ProxyContext.tsx +++ b/site/src/contexts/ProxyContext.tsx @@ -70,7 +70,6 @@ export const ProxyProvider: FC = ({ children }) => { onSuccess: (resp) => { setAndSaveProxy(proxy.selectedProxy, resp.regions) }, - enabled: experimentEnabled, }) const setAndSaveProxy = ( @@ -93,35 +92,18 @@ export const ProxyProvider: FC = ({ children }) => { setProxy(preferred) } - // ******************************* // - // ** This code can be removed ** - // ** when the experimental is ** - // ** dropped ** // - const appHostQueryKey = ["get-application-host"] - const { - data: applicationHostResult, - error: appHostError, - isLoading: appHostLoading, - isFetched: appHostFetched, - } = useQuery({ - queryKey: appHostQueryKey, - queryFn: getApplicationsHost, - enabled: !experimentEnabled, - }) - return ( Date: Mon, 8 May 2023 16:05:38 -0500 Subject: [PATCH 2/3] Add comment --- site/src/contexts/ProxyContext.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/src/contexts/ProxyContext.tsx b/site/src/contexts/ProxyContext.tsx index 8d65c9622bc12..24108436bf661 100644 --- a/site/src/contexts/ProxyContext.tsx +++ b/site/src/contexts/ProxyContext.tsx @@ -98,6 +98,8 @@ export const ProxyProvider: FC = ({ children }) => { proxy: experimentEnabled ? proxy : { + // If the experiment is disabled, then call 'getPreferredProxy' with the regions from + // the api call. The default behavior is to use the `primary` proxy. ...getPreferredProxy(proxiesResp?.regions || []), }, proxies: proxiesResp?.regions, From 62d8bb73d56f3bec6511427b6314fb96e0ed1759 Mon Sep 17 00:00:00 2001 From: Steven Masley Date: Mon, 8 May 2023 16:16:59 -0500 Subject: [PATCH 3/3] remove unused import --- site/src/contexts/ProxyContext.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/contexts/ProxyContext.tsx b/site/src/contexts/ProxyContext.tsx index 24108436bf661..c89ae309aecc8 100644 --- a/site/src/contexts/ProxyContext.tsx +++ b/site/src/contexts/ProxyContext.tsx @@ -1,5 +1,5 @@ import { useQuery } from "@tanstack/react-query" -import { getApplicationsHost, getWorkspaceProxies } from "api/api" +import { getWorkspaceProxies } from "api/api" import { Region } from "api/typesGenerated" import { useDashboard } from "components/Dashboard/DashboardProvider" import {