Skip to content

feat: add dismissed property to the healthcheck section #10940

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 17 commits into from
Nov 29, 2023
Merged
Prev Previous commit
Next Next commit
Dismissed property
  • Loading branch information
mtojek committed Nov 29, 2023
commit 29a5cda17955b81a8a0799af76a41cce406574c8
2 changes: 2 additions & 0 deletions coderd/healthcheck/accessurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ func (r *AccessURLReport) Run(ctx context.Context, opts *AccessURLReportOptions)

r.Severity = health.SeverityOK
r.Warnings = []string{}
r.Dismissed = opts.Dismissed

if opts.AccessURL == nil {
r.Error = ptr.Ref("access URL is nil")
r.Severity = health.SeverityError
Expand Down
2 changes: 2 additions & 0 deletions coderd/healthcheck/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type DatabaseReportOptions struct {
func (r *DatabaseReport) Run(ctx context.Context, opts *DatabaseReportOptions) {
r.Warnings = []string{}
r.Severity = health.SeverityOK
r.Dismissed = opts.Dismissed

r.ThresholdMS = opts.Threshold.Milliseconds()
if r.ThresholdMS == 0 {
r.ThresholdMS = DatabaseDefaultThreshold.Milliseconds()
Expand Down
12 changes: 6 additions & 6 deletions coderd/healthcheck/derphealth/derp.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ const (
// @typescript-generate Report
type Report struct {
// Healthy is deprecated and left for backward compatibility purposes, use `Severity` instead.
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Healthy bool `json:"healthy"`
Severity health.Severity `json:"severity" enums:"ok,warning,error"`
Warnings []string `json:"warnings"`
Dismissed bool `json:"dismissed`

Regions map[int]*RegionReport `json:"regions"`

Expand All @@ -47,8 +48,6 @@ type Report struct {
NetcheckLogs []string `json:"netcheck_logs"`

Error *string `json:"error"`

Dismissed bool `json:"dismissed`
}

// @typescript-generate RegionReport
Expand Down Expand Up @@ -105,9 +104,10 @@ type ReportOptions struct {
func (r *Report) Run(ctx context.Context, opts *ReportOptions) {
r.Healthy = true
r.Severity = health.SeverityOK
r.Warnings = []string{}
r.Dismissed = opts.Dismissed

r.Regions = map[int]*RegionReport{}
r.Warnings = []string{}

wg := &sync.WaitGroup{}
mu := sync.Mutex{}
Expand Down
18 changes: 10 additions & 8 deletions coderd/healthcheck/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ import (
"github.com/coder/coder/v2/coderd/healthcheck/health"
)

type WebsocketReportOptions struct {
APIKey string
AccessURL *url.URL
HTTPClient *http.Client

Dismissed bool
}

// @typescript-generate WebsocketReport
type WebsocketReport struct {
// Healthy is deprecated and left for backward compatibility purposes, use `Severity` instead.
Expand All @@ -36,12 +28,22 @@ type WebsocketReport struct {
Error *string `json:"error"`
}

type WebsocketReportOptions struct {
APIKey string
AccessURL *url.URL
HTTPClient *http.Client

Dismissed bool
}

func (r *WebsocketReport) Run(ctx context.Context, opts *WebsocketReportOptions) {
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

r.Severity = health.SeverityOK
r.Warnings = []string{}
r.Dismissed = opts.Dismissed

u, err := opts.AccessURL.Parse("/api/v2/debug/ws")
if err != nil {
r.Error = convertError(xerrors.Errorf("parse access url: %w", err))
Expand Down
19 changes: 10 additions & 9 deletions coderd/healthcheck/workspaceproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@ import (
"github.com/coder/coder/v2/codersdk"
)

type WorkspaceProxyReportOptions struct {
// CurrentVersion is the current server version.
// We pass this in to make it easier to test.
CurrentVersion string
WorkspaceProxiesFetchUpdater WorkspaceProxiesFetchUpdater

Dismissed bool
}

// @typescript-generate WorkspaceProxyReport
type WorkspaceProxyReport struct {
Healthy bool `json:"healthy"`
Expand All @@ -34,6 +25,15 @@ type WorkspaceProxyReport struct {
WorkspaceProxies codersdk.RegionsResponse[codersdk.WorkspaceProxy] `json:"workspace_proxies"`
}

type WorkspaceProxyReportOptions struct {
// CurrentVersion is the current server version.
// We pass this in to make it easier to test.
CurrentVersion string
WorkspaceProxiesFetchUpdater WorkspaceProxiesFetchUpdater

Dismissed bool
}

type WorkspaceProxiesFetchUpdater interface {
Fetch(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error)
Update(context.Context) error
Expand All @@ -55,6 +55,7 @@ func (r *WorkspaceProxyReport) Run(ctx context.Context, opts *WorkspaceProxyRepo
r.Healthy = true
r.Severity = health.SeverityOK
r.Warnings = []string{}
r.Dismissed = opts.Dismissed

if opts.WorkspaceProxiesFetchUpdater == nil {
opts.WorkspaceProxiesFetchUpdater = &AGPLWorkspaceProxiesFetchUpdater{}
Expand Down