Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11597b6

Browse files
committed
wire it up
1 parent3005ac8 commit11597b6

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

‎coderd/coderd.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,13 @@ type Options struct {
135135
AccessControlStore*atomic.Pointer[dbauthz.AccessControlStore]
136136
// AppSecurityKey is the crypto key used to sign and encrypt tokens related to
137137
// workspace applications. It consists of both a signing and encryption key.
138-
AppSecurityKey workspaceapps.SecurityKey
138+
AppSecurityKey workspaceapps.SecurityKey
139+
140+
// The following two functions are dependencies of HealthcheckFunc but are only implemented
141+
// in enterprise. Stubbing them out here.
142+
FetchWorkspaceProxiesFunc*atomic.Pointer[func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy],error)]
143+
UpdateProxyHealthFunc*atomic.Pointer[func(context.Context)error]
144+
139145
HealthcheckFuncfunc(ctx context.Context,apiKeystring)*healthcheck.Report
140146
HealthcheckTimeout time.Duration
141147
HealthcheckRefresh time.Duration
@@ -396,6 +402,15 @@ func New(options *Options) *API {
396402
*options.UpdateCheckOptions,
397403
)
398404
}
405+
406+
ifoptions.FetchWorkspaceProxiesFunc==nil {
407+
options.FetchWorkspaceProxiesFunc=&atomic.Pointer[func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy],error)]{}
408+
}
409+
410+
ifoptions.UpdateProxyHealthFunc==nil {
411+
options.UpdateProxyHealthFunc=&atomic.Pointer[func(context.Context)error]{}
412+
}
413+
399414
ifoptions.HealthcheckFunc==nil {
400415
options.HealthcheckFunc=func(ctx context.Context,apiKeystring)*healthcheck.Report {
401416
returnhealthcheck.Run(ctx,&healthcheck.ReportOptions{
@@ -413,9 +428,15 @@ func New(options *Options) *API {
413428
DerpHealth: derphealth.ReportOptions{
414429
DERPMap:api.DERPMap(),
415430
},
431+
WorkspaceProxy: healthcheck.WorkspaceProxyReportOptions{
432+
CurrentVersion:buildinfo.Version(),
433+
FetchWorkspaceProxies:*options.FetchWorkspaceProxiesFunc.Load(),
434+
UpdateProxyHealth:*options.UpdateProxyHealthFunc.Load(),
435+
},
416436
})
417437
}
418438
}
439+
419440
ifoptions.HealthcheckTimeout==0 {
420441
options.HealthcheckTimeout=30*time.Second
421442
}

‎coderd/healthcheck/workspaceproxy.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ import (
1010
)
1111

1212
typeWorkspaceProxyReportOptionsstruct {
13+
// CurrentVersion is the current server version.
14+
// We pass this in to make it easier to test.
15+
CurrentVersionstring
16+
// FetchWorkspaceProxies is a function that returns the available workspace proxies.
17+
FetchWorkspaceProxiesfunc(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy],error)
1318
// UpdateProxyHealth is a function called when healthcheck is run.
1419
// This would normally be ProxyHealth.ForceUpdate().
1520
// We do this because if someone mashes the healthcheck refresh button
1621
// they would expect up-to-date data.
1722
UpdateProxyHealthfunc(context.Context)error
18-
// FetchWorkspaceProxies is a function that returns the available workspace proxies.
19-
FetchWorkspaceProxiesfunc(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy],error)
20-
// CurrentVersion is the current server version.
21-
// We pass this in to make it easier to test.
22-
CurrentVersionstring
2323
}
2424

2525
// @typescript-generate Report

‎enterprise/coderd/coderd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/coder/coder/v2/coderd/httpmw"
3030
"github.com/coder/coder/v2/coderd/rbac"
3131
agplschedule"github.com/coder/coder/v2/coderd/schedule"
32+
"github.com/coder/coder/v2/coderd/util/ptr"
3233
"github.com/coder/coder/v2/codersdk"
3334
"github.com/coder/coder/v2/enterprise/coderd/dbauthz"
3435
"github.com/coder/coder/v2/enterprise/coderd/license"
@@ -374,6 +375,10 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
374375
// Use proxy health to return the healthy workspace proxy hostnames.
375376
f:=api.ProxyHealth.ProxyHosts
376377
api.AGPL.WorkspaceProxyHostsFn.Store(&f)
378+
379+
// Wire this up to healthcheck.
380+
api.AGPL.FetchWorkspaceProxiesFunc.Store(ptr.Ref(api.fetchWorkspaceProxies))
381+
api.AGPL.UpdateProxyHealthFunc.Store(ptr.Ref(api.ProxyHealth.ForceUpdate))
377382
}
378383

379384
err=api.PrometheusRegistry.Register(&api.licenseMetricsCollector)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp