Documentation
¶
Overview ¶
Package componenthealth contains the pure detection logic that turns the Kubernetes status of the managed cluster-level components (the Datadog Cluster Agent and Cluster Check Runners) into health issues. It is kept free of controller-runtime types so it can be unit-tested in isolation.
Index ¶
Constants ¶
const ( IssueOOMKilled = "component_oomkilled" IssueCrashLooping = "component_crash_looping" IssueUnschedulable = "component_unschedulable" IssueImagePullFailure = "image_pull_failure" )
Variables ¶
var AllIssueTypes = []string{ IssueOOMKilled, IssueCrashLooping, IssueUnschedulable, IssueImagePullFailure, }
AllIssueTypes is the catalog of issue types this package detects. It is used by the controller's startup resolve sweep to enumerate the issue space that may need an explicit RESOLVED signal after an operator restart.
Functions ¶
func ManagedComponent ¶
ManagedComponent returns the cluster-level component name for a pod, or "" if the pod is not one of the managed DCA/CLC components. Node Agents are intentionally excluded for now.
Types ¶
type ComponentIssue ¶
type ComponentIssue struct {
Component string // cluster-agent | cluster-checks-runner
IssueType string
Severity Severity
Namespace string
AffectedPods []string // names of the pods currently exhibiting the issue
// Lifecycle metadata, populated by the controller and reported to the backend
// (health-platform PersistedIssue). FirstSeen is when the issue first appeared,
// LastSeen is the last time it was observed active. ResolvedAt is set only for
// resolved issues (zero otherwise).
FirstSeen time.Time
LastSeen time.Time
ResolvedAt time.Time
}
ComponentIssue is a health issue reported at the component (deployment) level: the same IssueType affecting one or more pods of a component is a single issue instance. This is the unit the operator reports because it has stable identity across pod churn — pod names are ephemeral (a restart mints a new name), but the component is not. The affected pods are carried as detail.
It is emitter-agnostic: the caller decides how to report it (log, metric, or a health-platform payload sent to the backend).
type DetectedIssue ¶
type DetectedIssue struct {
Component string // cluster-agent | cluster-checks-runner
IssueType string
Severity Severity
Namespace string
PodName string
Container string // container the issue relates to, empty for pod-level issues
Reason string // raw Kubernetes reason (OOMKilled, CrashLoopBackOff, Unschedulable, ...)
Message string // human-readable detail
}
DetectedIssue is a single health problem detected on one managed component pod. It is the output of per-pod detection; the controller aggregates these into component-level ComponentIssues before reporting.
func DetectPodIssues ¶
func DetectPodIssues(pod *corev1.Pod, restartThreshold int32) []DetectedIssue
DetectPodIssues inspects a managed component pod's status and returns the health issues it exhibits. restartThreshold is the cumulative RestartCount at or above which a container is flagged as crash-looping even when it is not currently in CrashLoopBackOff; a value <= 0 disables that heuristic.
It returns nil for pods that are not managed DCA/CLC components.
type Severity ¶
type Severity string
Severity mirrors the health-platform severity levels.
func SeverityForIssueType ¶
SeverityForIssueType returns the catalog severity for a known issue type, or "" if it isn't one of the types this package detects.