Skip to content

Commit a31072a

Browse files
committed
Rename to host
1 parent 4f79fb6 commit a31072a

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

coderd/httpmw/csp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ func CSPHeaders(websocketHosts func() []string) func(next http.Handler) http.Han
101101
extraConnect := websocketHosts()
102102
if len(extraConnect) > 0 {
103103
for _, extraHost := range extraConnect {
104+
fmt.Println("extraHost", extraHost)
104105
cspSrcs.Append(cspDirectiveConnectSrc, fmt.Sprintf("wss://%[1]s ws://%[1]s", extraHost))
105106
}
106107
}

enterprise/coderd/coderd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func New(ctx context.Context, options *Options) (*API, error) {
252252
go api.forceWorkspaceProxyHealthUpdate(ctx)
253253

254254
// Use proxy health to return the healthy workspace proxy hostnames.
255-
f := api.ProxyHealth.HealthyHostnames
255+
f := api.ProxyHealth.HealthyHosts
256256
api.AGPL.HealthyWorkspaceProxyHosts.Store(&f)
257257
}
258258

enterprise/coderd/proxyhealth/proxyhealth.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,13 @@ func (p *ProxyHealth) storeProxyHealth(statuses map[uuid.UUID]ProxyStatus) {
146146
var healthyHosts []string
147147
for _, s := range statuses {
148148
if s.Status == Healthy {
149-
healthyHosts = append(healthyHosts, s.ProxyHostname)
149+
healthyHosts = append(healthyHosts, s.ProxyHost)
150150
}
151151
}
152152

153153
// Store the statuses in the cache before any other quick values.
154154
p.cache.Store(&statuses)
155+
fmt.Println(healthyHosts)
155156
p.heathyHosts.Store(&healthyHosts)
156157
}
157158

@@ -178,11 +179,11 @@ func (p *ProxyHealth) HealthStatus() map[uuid.UUID]ProxyStatus {
178179
return *ptr
179180
}
180181

181-
// HealthyHostnames returns the hostnames of all healthy proxies.
182+
// HealthyHosts returns the host:port of all healthy proxies.
182183
// This can be computed from HealthStatus, but is cached to avoid the
183184
// caller needing to loop over all proxies to compute this on all
184185
// static web requests.
185-
func (p *ProxyHealth) HealthyHostnames() []string {
186+
func (p *ProxyHealth) HealthyHosts() []string {
186187
ptr := p.heathyHosts.Load()
187188
if ptr == nil {
188189
return []string{}
@@ -196,13 +197,13 @@ type ProxyStatus struct {
196197
// then the proxy in hand. AKA if the proxy was updated, and the status was for
197198
// an older proxy.
198199
Proxy database.WorkspaceProxy
199-
// ProxyHostname is the hostname of the proxy url. This is included in the status
200+
// ProxyHost is the host:port of the proxy url. This is included in the status
200201
// to make sure the proxy url is a valid URL. It also makes it easier to
201202
// escalate errors if the url.Parse errors (should never happen).
202-
ProxyHostname string
203-
Status Status
204-
Report codersdk.ProxyHealthReport
205-
CheckedAt time.Time
203+
ProxyHost string
204+
Status Status
205+
Report codersdk.ProxyHealthReport
206+
CheckedAt time.Time
206207
}
207208

208209
// runOnce runs the health check for all workspace proxies. If there is an
@@ -288,7 +289,7 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID
288289
break
289290
}
290291
status.Status = Healthy
291-
status.ProxyHostname = u.Hostname()
292+
status.ProxyHost = u.Host
292293
case err == nil && resp.StatusCode != http.StatusOK:
293294
// Unhealthy as we did reach the proxy but it got an unexpected response.
294295
status.Status = Unhealthy

0 commit comments

Comments
 (0)