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