Skip to content

chore: Drop application host call, default to regions for info #7457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions coderd/workspaceapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() != "" {
Expand Down
32 changes: 8 additions & 24 deletions site/src/contexts/ProxyContext.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -70,7 +70,6 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
onSuccess: (resp) => {
setAndSaveProxy(proxy.selectedProxy, resp.regions)
},
enabled: experimentEnabled,
})

const setAndSaveProxy = (
Expand All @@ -93,35 +92,20 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ 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 (
<ProxyContext.Provider
value={{
proxy: experimentEnabled
? proxy
: {
...getPreferredProxy([]),
preferredWildcardHostname: applicationHostResult?.host || "",
// 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: experimentEnabled ? proxiesResp?.regions : [],
isLoading: experimentEnabled ? proxiesLoading : appHostLoading,
isFetched: experimentEnabled ? proxiesFetched : appHostFetched,
error: experimentEnabled ? proxiesError : appHostError,
proxies: proxiesResp?.regions,
isLoading: proxiesLoading,
isFetched: proxiesFetched,
error: proxiesError,
// A function that takes the new proxies and selected proxy and updates
// the state with the appropriate urls.
setProxy: setAndSaveProxy,
Expand Down