mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
address comments
Change-Id: I9c9854b8bb3221e4791c70f566361bd0421061c1
This commit is contained in:
parent
895c80be2a
commit
822c52c220
@ -27,32 +27,33 @@ import (
|
||||
type HealthcheckStatus string
|
||||
|
||||
const (
|
||||
SUCCESS HealthcheckStatus = "success"
|
||||
ERROR HealthcheckStatus = "error"
|
||||
PENDING HealthcheckStatus = "pending"
|
||||
Success HealthcheckStatus = "success"
|
||||
Error HealthcheckStatus = "error"
|
||||
Pending HealthcheckStatus = "pending"
|
||||
)
|
||||
|
||||
type HealthcheckType string
|
||||
|
||||
const (
|
||||
LIVEZ HealthcheckType = "livez"
|
||||
READYZ HealthcheckType = "readyz"
|
||||
HEALTHZ HealthcheckType = "healthz"
|
||||
Livez HealthcheckType = "livez"
|
||||
Readyz HealthcheckType = "readyz"
|
||||
Healthz HealthcheckType = "healthz"
|
||||
)
|
||||
|
||||
var (
|
||||
// healthcheck is a Prometheus Gauge metrics used for recording the results of a k8s healthcheck.
|
||||
healthcheck = k8smetrics.NewGaugeVec(
|
||||
&k8smetrics.GaugeOpts{
|
||||
Name: "k8s_healthcheck",
|
||||
Help: "This metric records the result of a single health check.",
|
||||
Namespace: "k8s",
|
||||
Name: "healthcheck",
|
||||
Help: "This metric records the result of a single healthcheck.",
|
||||
StabilityLevel: k8smetrics.ALPHA,
|
||||
},
|
||||
[]string{"name", "type", "status"},
|
||||
)
|
||||
statuses = []HealthcheckStatus{SUCCESS, ERROR, PENDING}
|
||||
statusSet = map[HealthcheckStatus]struct{}{SUCCESS: {}, ERROR: {}, PENDING: {}}
|
||||
checkSet = map[HealthcheckType]struct{}{LIVEZ: {}, READYZ: {}, HEALTHZ: {}}
|
||||
statuses = []HealthcheckStatus{Success, Error, Pending}
|
||||
statusSet = map[HealthcheckStatus]struct{}{Success: {}, Error: {}, Pending: {}}
|
||||
checkSet = map[HealthcheckType]struct{}{Livez: {}, Readyz: {}, Healthz: {}}
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
@ -32,10 +32,10 @@ var (
|
||||
func TestObserveHealthcheck(t *testing.T) {
|
||||
defer legacyregistry.Reset()
|
||||
defer ResetHealthMetrics()
|
||||
initialState := ERROR
|
||||
initialState := Error
|
||||
healthcheckName := "healthcheck-a"
|
||||
initialOutput := `
|
||||
# HELP k8s_healthcheck [ALPHA] This metric records the result of a single health check.
|
||||
# HELP k8s_healthcheck [ALPHA] This metric records the result of a single healthcheck.
|
||||
# TYPE k8s_healthcheck gauge
|
||||
k8s_healthcheck{name="healthcheck-a",status="error",type="healthz"} 1
|
||||
k8s_healthcheck{name="healthcheck-a",status="pending",type="healthz"} 0
|
||||
@ -51,10 +51,10 @@ func TestObserveHealthcheck(t *testing.T) {
|
||||
{
|
||||
desc: "test pending",
|
||||
name: healthcheckName,
|
||||
hcType: HEALTHZ,
|
||||
hcStatus: PENDING,
|
||||
hcType: Healthz,
|
||||
hcStatus: Pending,
|
||||
want: `
|
||||
# HELP k8s_healthcheck [ALPHA] This metric records the result of a single health check.
|
||||
# HELP k8s_healthcheck [ALPHA] This metric records the result of a single healthcheck.
|
||||
# TYPE k8s_healthcheck gauge
|
||||
k8s_healthcheck{name="healthcheck-a",status="error",type="healthz"} 0
|
||||
k8s_healthcheck{name="healthcheck-a",status="pending",type="healthz"} 1
|
||||
@ -64,10 +64,10 @@ func TestObserveHealthcheck(t *testing.T) {
|
||||
{
|
||||
desc: "test success",
|
||||
name: healthcheckName,
|
||||
hcType: HEALTHZ,
|
||||
hcStatus: SUCCESS,
|
||||
hcType: Healthz,
|
||||
hcStatus: Success,
|
||||
want: `
|
||||
# HELP k8s_healthcheck [ALPHA] This metric records the result of a single health check.
|
||||
# HELP k8s_healthcheck [ALPHA] This metric records the result of a single healthcheck.
|
||||
# TYPE k8s_healthcheck gauge
|
||||
k8s_healthcheck{name="healthcheck-a",status="error",type="healthz"} 0
|
||||
k8s_healthcheck{name="healthcheck-a",status="pending",type="healthz"} 0
|
||||
|
Loading…
Reference in New Issue
Block a user