Documentation
¶
Index ¶
- Constants
- Variables
- type CRConditionsSection
- type ComponentStatusResult
- type ConditionSummary
- type Config
- type ContainerInfo
- type DependentOperatorResult
- type DeploymentInfo
- type DeploymentsSection
- type EventInfo
- type EventsSection
- type NamespaceConfig
- type NodeInfo
- type NodesSection
- type OperatorConfig
- type OperatorSection
- type OperatorSectionData
- type PodInfo
- type PodsSection
- type QuotasSection
- type RecentEventsConfig
- type Report
- type ResourceQuotaInfo
- type SectionResult
- type UnhealthyChecker
Constants ¶
const ( SectionNodes = "nodes" SectionDeployments = "deployments" SectionPods = "pods" SectionEvents = "events" SectionQuotas = "quotas" SectionOperator = "operator" SectionDSCI = "dsci" SectionDSC = "dsc" )
Section name constants for use in Config.OnlySections.
const ( // LayerInfrastructure is cluster-level health: nodes and resource quotas. LayerInfrastructure = "infrastructure" // LayerWorkload is on-cluster components: deployments, pods, events, operator, DSCI, DSC. LayerWorkload = "workload" // LayerOperator is operator and CRs: operator deployment, DSCI, DSC. LayerOperator = "operator" )
Layer name constants. Layers group sections for common use cases. Use Config.Layers to run only checks in one or more layers.
const DefaultEventsWindow = 5 * time.Minute
Variables ¶
var ( DSCInitializationGVK = schema.GroupVersionKind{ Group: "dscinitialization.opendatahub.io", Version: "v2", Kind: "DSCInitialization", } DataScienceClusterGVK = schema.GroupVersionKind{ Group: "datasciencecluster.opendatahub.io", Version: "v2", Kind: "DataScienceCluster", } )
GVKs for the ODH custom resources checked by the DSCI and DSC sections.
var KnownComponents = map[string]string{
"dashboard": "Dashboard", "workbenches": "Workbenches",
"kserve": "Kserve", "ray": "Ray", "kueue": "Kueue",
"modelregistry": "ModelRegistry", "trustyai": "TrustyAI",
"datasciencepipelines": "DataSciencePipelines",
"trainingoperator": "TrainingOperator", "feastoperator": "FeastOperator",
"llamastackoperator": "LlamaStackOperator", "modelmeshserving": "ModelMeshServing",
"mlflowoperator": "MLflowOperator", "sparkoperator": "SparkOperator",
"modelcontroller": "ModelController", "modelsasservice": "ModelsAsService",
"trainer": "Trainer",
}
KnownComponents maps component name (user-facing) to CR Kind.
Functions ¶
This section is empty.
Types ¶
type CRConditionsSection ¶
type CRConditionsSection struct {
Name string `json:"name"`
Conditions []ConditionSummary `json:"conditions"`
Data *unstructured.Unstructured `json:"data,omitempty"` // raw CR for tests or fields we don't parse
}
type ComponentStatusResult ¶
type ComponentStatusResult struct {
Component string `json:"component"`
CRFound bool `json:"crFound"`
Conditions []ConditionSummary `json:"conditions"`
Deployments []DeploymentInfo `json:"deployments"`
Pods []PodInfo `json:"pods"`
Errors []string `json:"errors,omitempty"`
}
ComponentStatusResult holds the health details for a single ODH component.
func GetComponentStatus ¶
func GetComponentStatus(ctx context.Context, c client.Client, name, appsNS string) (*ComponentStatusResult, error)
GetComponentStatus fetches the CR conditions, deployments, and pods for a named component.
type ConditionSummary ¶
type Config ¶
type Config struct {
Client client.Client
Operator OperatorConfig
Namespaces NamespaceConfig
DSCI types.NamespacedName
DSC types.NamespacedName
// OnlySections limits which sections to run. Empty or nil = run all.
// Use section constants (SectionNodes, SectionDeployments, etc.) or layer
// constants (LayerInfrastructure, LayerWorkload, LayerOperator) to run a subset.
OnlySections []string
// Layers limits which sections to run. Empty or nil = run all.
Layers []string
}
Config holds the client and namespace needed to run health checks. All inputs are passed explicitly; no package-level globals.
type ContainerInfo ¶
type ContainerInfo struct {
Name string `json:"name"`
Ready bool `json:"ready"`
IsInit bool `json:"isInit,omitempty"`
RestartCount int32 `json:"restartCount"`
Waiting string `json:"waiting"` // reason/message if waiting
Terminated string `json:"terminated"` // reason/exit if terminated
RequestsCPU *int64 `json:"requestsCPU,omitempty"` // in millicores
RequestsMemory *int64 `json:"requestsMemory,omitempty"` // in bytes
LimitsCPU *int64 `json:"limitsCPU,omitempty"` // in millicores
LimitsMemory *int64 `json:"limitsMemory,omitempty"` // in bytes
}
type DependentOperatorResult ¶
type DependentOperatorResult struct {
Name string `json:"name"`
Installed bool `json:"installed"` // true if a deployment was found in the dependent's namespace
Deployment *DeploymentInfo `json:"deployment,omitempty"`
Pods []PodInfo `json:"pods,omitempty"`
Error string `json:"error,omitempty"`
}
type DeploymentInfo ¶
type DeploymentInfo struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Ready int32 `json:"ready"`
Replicas int32 `json:"replicas"`
Conditions []ConditionSummary `json:"conditions"`
}
type DeploymentsSection ¶
type DeploymentsSection struct {
ByNamespace map[string][]DeploymentInfo `json:"byNamespace"`
Data []appsv1.Deployment `json:"data,omitempty"` // raw Deployment list for tests or fields we don't parse
}
type EventInfo ¶
type EventInfo struct {
Namespace string `json:"namespace"`
Kind string `json:"kind"`
Name string `json:"name"`
Type string `json:"type"`
Reason string `json:"reason"`
Message string `json:"message"`
LastTime time.Time `json:"lastTime"`
}
func RunRecentEvents ¶
func RunRecentEvents(ctx context.Context, cfg RecentEventsConfig) ([]EventInfo, error)
RunRecentEvents returns recent events across namespaces, filtered by type and sorted most-recent-first.
type EventsSection ¶
type NamespaceConfig ¶
NamespaceConfig configures which namespaces to scan for deployments, pods, events, quotas. None are required; empty or zero values are valid. If List() returns no namespaces, those sections return empty data with no error. The Nodes section does not use namespaces.
func (NamespaceConfig) List ¶
func (n NamespaceConfig) List() []string
List returns the deduplicated list of namespaces to scan, skipping empty ones. When Apps and Monitoring point to the same namespace (common in ODH), the namespace appears only once to avoid duplicate API calls and metric lines.
type NodeInfo ¶
type NodeInfo struct {
Name string `json:"name"`
Role string `json:"role,omitempty"` // e.g. "master" or "worker"
Conditions []ConditionSummary `json:"conditions"`
Allocatable string `json:"allocatable"` // human-readable (e.g. "4 CPU, 8Gi memory")
Capacity string `json:"capacity"`
UnhealthyReason string `json:"unhealthyReason,omitempty"` // non-empty if node is in a bad state
// Actual resource usage from the Metrics Server (nil when unavailable).
UsageCPUMillicores *int64 `json:"usageCPUMillicores,omitempty"`
UsageMemoryBytes *int64 `json:"usageMemoryBytes,omitempty"`
}
type NodesSection ¶
type OperatorConfig ¶
OperatorConfig configures which operator deployment and namespace to check. The deployment name is supplied by the caller (e.g. from platform: ODH vs RHODS operator).
type OperatorSection ¶
type OperatorSection struct {
Deployment *DeploymentInfo `json:"deployment"`
Pods []PodInfo `json:"pods"`
DependentOperators []DependentOperatorResult `json:"dependentOperators,omitempty"`
Data *OperatorSectionData `json:"data,omitempty"` // raw Deployment and Pods for tests or fields we don't parse
}
type OperatorSectionData ¶
type OperatorSectionData struct {
Deployment *appsv1.Deployment `json:"deployment,omitempty"`
Pods []corev1.Pod `json:"pods,omitempty"`
}
type PodsSection ¶
type QuotasSection ¶
type QuotasSection struct {
ByNamespace map[string][]ResourceQuotaInfo `json:"byNamespace"`
Data []corev1.ResourceQuota `json:"data,omitempty"` // raw ResourceQuota list for tests or fields we don't parse
}
type RecentEventsConfig ¶
type RecentEventsConfig struct {
Client client.Client
Namespaces []string // namespaces to scan (caller resolves these)
Since time.Duration // look-back window; zero = DefaultEventsWindow (5m)
EventType string // "Warning", "Normal", or "" for all
}
RecentEventsConfig holds parameters for a standalone recent-events query.
type Report ¶
type Report struct {
CollectedAt time.Time `json:"collectedAt"`
// SectionsRun is the list of section names that were executed (e.g. when using OnlySections or Layers).
// Empty or nil means all sections were run. Used by PrettyPrint to show only those rows.
SectionsRun []string `json:"sectionsRun,omitempty"`
Nodes SectionResult[NodesSection] `json:"nodes"`
Deployments SectionResult[DeploymentsSection] `json:"deployments"`
Pods SectionResult[PodsSection] `json:"pods"`
Events SectionResult[EventsSection] `json:"events"`
Quotas SectionResult[QuotasSection] `json:"quotas"`
Operator SectionResult[OperatorSection] `json:"operator"`
DSCI SectionResult[CRConditionsSection] `json:"dsci"`
DSC SectionResult[CRConditionsSection] `json:"dsc"`
}
Report is the full result of Run(). All sections are independent; partial failures are recorded per section.
func Run ¶
Run runs all health checks and returns a Report. Config.Client and namespace configuration must be set by the caller; no globals are used.
Run always returns a non-nil Report when err is nil. It returns an error only when the report cannot be built at all (e.g. nil client). Partial failures are recorded per section in the Report (SectionResult.Error and optional Data).
func (*Report) Healthy ¶
Healthy returns true if the report has no section errors (all checks succeeded or returned partial data without a fatal error). Used by CLI to decide exit code.
func (*Report) PrettyPrint ¶
PrettyPrint returns a human-readable table of section results. When Report.SectionsRun is set (e.g. from -sections or -layer), only those sections are shown; otherwise all eight are shown. If long is true, appends a details block listing conditions and other per-item data (like ls -l).
func (*Report) PrometheusExport ¶
PrometheusExport converts the Report to Prometheus exposition format lines. Each line includes the CollectedAt timestamp in Unix seconds. The output can be appended to a file for bulk import into VictoriaMetrics via /api/v1/import/prometheus.
type ResourceQuotaInfo ¶
type SectionResult ¶
type SectionResult[T any] struct { Error string `json:"error"` // non-empty if this section failed or was skipped Data T `json:"data"` // populated with whatever was collected (may be zero value) }
SectionResult carries the result of one health-check section: optional error and typed data. Partial failures set Error and may still populate Data with what was collected.
type UnhealthyChecker ¶
type UnhealthyChecker func(obj map[string]any, conditions []ConditionSummary) []string
UnhealthyChecker is the common signature for kind-specific condition checks. Receives the raw CR object and parsed conditions; returns messages for any conditions that count as unhealthy.