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

feat(coderd/healthcheck): add health check for proxy#10846

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 24 commits intomainfromcj/workspaceproxy-healthcheck
Nov 24, 2023

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedNov 23, 2023
edited
Loading

Fixes#9558

Adds a health check for workspace proxies:

  • Healthy iff all proxies are healthy and the same version,
  • Warning if some proxies are unhealthy,
  • Error if all proxies are unhealthy, or do not all have the same version.

@johnstcnjohnstcn changed the titleWIP[wip] feat(coderd/healthcheck): add health check for proxyNov 23, 2023
@johnstcnjohnstcnforce-pushed thecj/workspaceproxy-healthcheck branch from84b0060 toe80c05dCompareNovember 23, 2023 12:56
@johnstcnjohnstcnforce-pushed thecj/workspaceproxy-healthcheck branch from11597b6 toc7e202cCompareNovember 23, 2023 15:16
@johnstcnjohnstcn changed the title[wip] feat(coderd/healthcheck): add health check for proxyfeat(coderd/healthcheck): add health check for proxyNov 23, 2023
@johnstcnjohnstcn marked this pull request as ready for reviewNovember 24, 2023 09:33
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good test coverage, minor things only.

AppSecurityKey workspaceapps.SecurityKey
AppSecurityKey workspaceapps.SecurityKey

// The following two functions are dependencies of HealthcheckFunc but are only implemented
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

maybe move the comment to the place where you assign these no-op{}

johnstcn reacted with thumbs up emoji
@@ -153,6 +174,9 @@ func Run(ctx context.Context, opts *ReportOptions) *Report {
if !report.Database.Healthy {
report.FailingSections = append(report.FailingSections, SectionDatabase)
}
if !report.WorkspaceProxy.Healthy {
report.FailingSections = append(report.FailingSections, SectionWorkspaceProxy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

side thought: frontend does not useFailingSections at all. Maybe we should remove it for simplicity.

Copy link
MemberAuthor

@johnstcnjohnstcnNov 24, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍 Will file a follow-up PR

Edit:#10854

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it's beneficial to have a structure that can be navigated in a generic way.

for(letsectionofreport.failing_sections){console.log(report[section].reason);}

Given a good design, it will "always works", even when new fields and structures are added. Granted, I'm not a proponent for the current design, just for the ability to do so.

// health.SeverityError if all proxies are unhealthy,
// health.SeverityOK if all proxies are healthy,
// health.SeverityWarning otherwise.
func calculateSeverity(total, healthy int) health.Severity {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

TBH this could probably be moved to a separateutils file

mtojek reacted with thumbs up emoji
},
}, nil
}),
updateProxyHealth: ptr.Ref(func(ctx context.Context) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: you can create a no-op function somewhere around, and just refer to it

johnstcn reacted with thumbs up emoji
@@ -396,9 +402,19 @@ func New(options *Options) *API {
*options.UpdateCheckOptions,
)
}

if options.FetchWorkspaceProxiesFunc == nil {
options.FetchWorkspaceProxiesFunc = &atomic.Pointer[func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error)]{}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Random comment: This looks pretty gnarly (generics within generics), I kind of get why the Go team delayed generics for as long as they did. 😄

johnstcn reacted with laugh emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

To be fair, generics within generics look gnarly in any language!

@@ -153,6 +174,9 @@ func Run(ctx context.Context, opts *ReportOptions) *Report {
if !report.Database.Healthy {
report.FailingSections = append(report.FailingSections, SectionDatabase)
}
if !report.WorkspaceProxy.Healthy {
report.FailingSections = append(report.FailingSections, SectionWorkspaceProxy)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think it's beneficial to have a structure that can be navigated in a generic way.

for(letsectionofreport.failing_sections){console.log(report[section].reason);}

Given a good design, it will "always works", even when new fields and structures are added. Granted, I'm not a proponent for the current design, just for the ability to do so.

for _, proxy := range r.WorkspaceProxies.Regions {
if vErr := checkVersion(proxy, opts.CurrentVersion); vErr != nil {
r.Healthy = false
r.Severity = health.SeverityError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Not suggesting, just asking: Is this always an error? Could it be a warning instead if it's a patch version difference, for instance?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Our current behaviour won't even let workspace proxies register if they don't match major.minor, but makes no further complaints if it's just a patch version difference.

Making it warn on a patch version difference sounds like a good idea in theory, but it will mean every time you upgrade, you'll get a short period of warning that there's a patch version diff. Although that's the current behaviour as well when you do a major version upgrade, so... 🤷

I'll see about adding it in a follow-up.

mafredri reacted with thumbs up emoji
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM!

// in an actually useful and meaningful way.
type workspaceProxiesFetchUpdater struct {
fetchFunc func(context.Context) (codersdk.RegionsResponse[codersdk.WorkspaceProxy], error)
updateFunc func(context.Context) error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggestion: You could either export this as-is to re-use in tests, or you could simplify this to just pass in the whole API (api *coderd.API) and call it from the methods.

@johnstcnjohnstcn merged commit411ce46 intomainNov 24, 2023
@johnstcnjohnstcn deleted the cj/workspaceproxy-healthcheck branchNovember 24, 2023 15:06
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsNov 24, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@mtojekmtojekmtojek approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

add health check for proxy
3 participants
@johnstcn@mafredri@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp