MCPcopy
hub / github.com/kubernetes/node-problem-detector / NewHealthChecker

Function NewHealthChecker

pkg/healthchecker/health_checker.go:49–64  ·  view source on GitHub ↗

NewHealthChecker returns a new health checker configured with the given options.

(hco *options.HealthCheckerOptions)

Source from the content-addressed store, hash-verified

47
48// NewHealthChecker returns a new health checker configured with the given options.
49func NewHealthChecker(hco *options.HealthCheckerOptions) (types.HealthChecker, error) {
50 hc := &healthChecker{
51 component: hco.Component,
52 enableRepair: hco.EnableRepair,
53 crictlPath: hco.CriCtlPath,
54 healthCheckTimeout: hco.HealthCheckTimeout,
55 coolDownTime: hco.CoolDownTime,
56 service: hco.Service,
57 loopBackTime: hco.LoopBackTime,
58 logPatternsToCheck: hco.LogPatterns.GetLogPatternCountMap(),
59 }
60 hc.healthCheckFunc = getHealthCheckFunc(hco)
61 hc.repairFunc = getRepairFunc(hco)
62 hc.uptimeFunc = getUptimeFunc(hco.Service)
63 return hc, nil
64}
65
66// CheckHealth checks for the health of the component and tries to repair if enabled.
67// Returns true if healthy, false otherwise.

Callers 1

mainFunction · 0.92

Calls 4

getHealthCheckFuncFunction · 0.85
GetLogPatternCountMapMethod · 0.80
getRepairFuncFunction · 0.70
getUptimeFuncFunction · 0.70

Tested by

no test coverage detected