Documentation
¶
Overview ¶
Package healthmonitoring joins the health reports of one cluster with the ClusterSummaries that own the HealthChecks behind them. It has no client and no locks: callers (ui-backend, sveltosctl) build the inputs from their own caches or from Lists and pass them in, so the cluster list and the per-cluster detail are computed by the same code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneratedCheckOwner ¶
func GeneratedCheckOwner(obj metav1.Object) (*corev1.ObjectReference, bool)
GeneratedCheckOwner returns the ClusterSummary a HealthCheck has been generated for. It reads only the metadata, so a metadata only cache is enough. The returned bool is false when the object does not carry the labels and annotations of a generated check.
Types ¶
type ClusterHealth ¶
type ClusterHealth struct {
State State
// Profiles has one entry per ClusterSummary with health monitoring enabled.
Profiles []ProfileHealth
// Resources are the resources not Healthy, one entry per resource: the ones owned by a
// profile first, then the ones no profile owns. Within each group worst status first.
Resources []UnhealthyResource
}
ClusterHealth is the result of Evaluate for one cluster.
func Evaluate ¶
func Evaluate(summaries []SummaryInput, reports []ReportInput) ClusterHealth
Evaluate runs the join for ONE cluster: pass only the ClusterSummaries and the reports of that cluster.
- A summary owns its generated HealthCheck and the ones its profile lists.
- A report is attributed to every enabled summary owning its HealthCheck. A report nobody owns is "unclaimed" and its resources carry the HealthCheck name instead of profiles. Unclaimed reports are listed even when no profile has monitoring enabled.
- A resource reported by several checks is listed once. When a profile owns one of the reports, the status and message come from the reports owned by profiles; otherwise from the unclaimed ones. Among reports of the same kind the worst status wins.
- A profile has no data until a report of one of its checks exists. A report with no unhealthy resources makes it Healthy.
- The cluster state is the worst state among the profiles and the listed resources. It is Healthy when a report exists and nothing is unhealthy.
- NotEnabled is returned only when no profile has monitoring enabled and there is no report.
type ProfileHealth ¶
type ProfileHealth struct {
Profile corev1.ObjectReference
Summary corev1.ObjectReference
State State
}
ProfileHealth is the health state of one profile on the cluster.
type ReportInput ¶
type ReportInput struct {
HealthCheckName string
Resources []ResourceInput
}
ReportInput is the compact copy of one HealthCheckReport of the cluster.
func NewReportInput ¶
func NewReportInput(report *libsveltosv1beta1.HealthCheckReport) ReportInput
NewReportInput builds the input for a HealthCheckReport.
type ResourceInput ¶
type ResourceInput struct {
ObjectRef corev1.ObjectReference
Status libsveltosv1beta1.HealthStatus
Message string
}
ResourceInput is the status of one resource in a report.
type State ¶
type State string
State is the health state of a profile or of a cluster.
const ( // StateNotEnabled means nothing is monitored: no profile has health monitoring enabled // and no HealthCheckReport exists for the cluster. StateNotEnabled State = "NotEnabled" // StateNoData means monitoring is enabled but no report has been received yet. StateNoData State = "NoData" StateHealthy State = "Healthy" StateSuspended State = "Suspended" StateProgressing State = "Progressing" StateDegraded State = "Degraded" )
func StateOf ¶
func StateOf(status libsveltosv1beta1.HealthStatus) State
StateOf converts the status of a resource into a State.
func WorstState ¶
WorstState returns the worse of two states. From best to worst: NotEnabled, NoData, Healthy, Suspended, Progressing, Degraded.
type SummaryInput ¶
type SummaryInput struct {
// Summary is the ClusterSummary.
Summary corev1.ObjectReference
// Profile is the ClusterProfile or Profile owning the ClusterSummary.
Profile corev1.ObjectReference
// Enabled is true when the profile has health monitoring enabled.
Enabled bool
// ListedChecks are the HealthCheck names the profile lists in healthMonitoring.healthChecks.
ListedChecks []string
// GeneratedCheck is the name of the HealthCheck generated for the ClusterSummary,
// empty if it has not been created yet.
GeneratedCheck string
}
SummaryInput is what the join needs from one ClusterSummary.
func NewSummaryInput ¶
func NewSummaryInput(clusterSummary *configv1beta1.ClusterSummary, generatedCheck string) (SummaryInput, error)
NewSummaryInput builds the input for a ClusterSummary. generatedCheck is the name of the HealthCheck generated for it, empty if unknown. Listed HealthChecks are honored for a ClusterProfile only: a Profile gets the default checks only (see HealthMonitoring.HealthChecks).
type UnhealthyResource ¶
type UnhealthyResource struct {
ObjectRef corev1.ObjectReference
Status libsveltosv1beta1.HealthStatus
Message string
// Profiles are the profiles owning the HealthCheck that reported the resource.
// Empty when no profile owns it.
Profiles []corev1.ObjectReference
// HealthCheckName is the HealthCheck that reported the resource. Set only when Profiles is empty.
HealthCheckName string
}
UnhealthyResource is a resource reported not Healthy.