feat(coderd/healthcheck): allow configuring database hc threshold (#10623)

* feat(coderd/healthcheck): allow configuring database hc threshold
* feat(coderd): add database hc latency, plumb through
* feat(coderd): allow configuring healthcheck refresh interval
This commit is contained in:
Cian Johnston
2023-11-13 14:14:43 +00:00
committed by GitHub
parent e4211ccb40
commit b69c237b8a
17 changed files with 288 additions and 55 deletions
+33
View File
@@ -183,6 +183,7 @@ type DeploymentValues struct {
EnableTerraformDebugMode clibase.Bool `json:"enable_terraform_debug_mode,omitempty" typescript:",notnull"`
UserQuietHoursSchedule UserQuietHoursScheduleConfig `json:"user_quiet_hours_schedule,omitempty" typescript:",notnull"`
WebTerminalRenderer clibase.String `json:"web_terminal_renderer,omitempty" typescript:",notnull"`
Healthcheck HealthcheckConfig `json:"healthcheck,omitempty" typescript:",notnull"`
Config clibase.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"`
WriteConfig clibase.Bool `json:"write_config,omitempty" typescript:",notnull"`
@@ -395,6 +396,12 @@ type UserQuietHoursScheduleConfig struct {
// WindowDuration clibase.Duration `json:"window_duration" typescript:",notnull"`
}
// HealthcheckConfig contains configuration for healthchecks.
type HealthcheckConfig struct {
Refresh clibase.Duration `json:"refresh" typescript:",notnull"`
ThresholdDatabase clibase.Duration `json:"threshold_database" typescript:",notnull"`
}
const (
annotationEnterpriseKey = "enterprise"
annotationSecretKey = "secret"
@@ -489,6 +496,11 @@ func (c *DeploymentValues) Options() clibase.OptionSet {
Name: "Logging",
YAML: "logging",
}
deploymentGroupIntrospectionHealthcheck = clibase.Group{
Parent: &deploymentGroupIntrospection,
Name: "Health Check",
YAML: "healthcheck",
}
deploymentGroupOAuth2 = clibase.Group{
Name: "OAuth2",
Description: `Configure login and user-provisioning with GitHub via oAuth2.`,
@@ -1799,6 +1811,27 @@ Write out the current server config as YAML to stdout.`,
Group: &deploymentGroupClient,
YAML: "webTerminalRenderer",
},
// Healthcheck Options
{
Name: "Health Check Refresh",
Description: "Refresh interval for healthchecks.",
Flag: "health-check-refresh",
Env: "CODER_HEALTH_CHECK_REFRESH",
Default: (10 * time.Minute).String(),
Value: &c.Healthcheck.Refresh,
Group: &deploymentGroupIntrospectionHealthcheck,
YAML: "refresh",
},
{
Name: "Health Check Threshold: Database",
Description: "The threshold for the database health check. If the median latency of the database exceeds this threshold over 5 attempts, the database is considered unhealthy. The default value is 15ms.",
Flag: "health-check-threshold-database",
Env: "CODER_HEALTH_CHECK_THRESHOLD_DATABASE",
Default: (15 * time.Millisecond).String(),
Value: &c.Healthcheck.ThresholdDatabase,
Group: &deploymentGroupIntrospectionHealthcheck,
YAML: "thresholdDatabase",
},
}
return opts