componenthealth

package
v1.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const (
	IssueOOMKilled        = "component_oomkilled"
	IssueCrashLooping     = "component_crash_looping"
	IssueUnschedulable    = "component_unschedulable"
	IssueImagePullFailure = "image_pull_failure"
)

Variables

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

func ManagedComponent(pod *corev1.Pod) string

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.

const (
	SeverityHigh   Severity = "high"
	SeverityMedium Severity = "medium"
	SeverityLow    Severity = "low"
)

func SeverityForIssueType

func SeverityForIssueType(issueType string) Severity

SeverityForIssueType returns the catalog severity for a known issue type, or "" if it isn't one of the types this package detects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL