status

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package status provides shared helpers for managing the lifecycle state of Multigres Custom Resources.

It contains utilities for:

  • Computing resource Phase (Initializing / Progressing / Healthy) from replica counts via ComputePhase.
  • Managing metav1.Condition slices (SetCondition, IsConditionTrue) used by data-handler controllers to track topology registration, backup health, and similar observable state.

These helpers are intentionally kept in a shared package so that both the Cell and Shard data-handler controllers (and any future controllers) use a single implementation rather than duplicating condition logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyCrashLooping

func AnyCrashLooping(pods []corev1.Pod) bool

AnyCrashLooping returns true if any non-terminating pod in the slice is crash-looping.

func ComputePhase

func ComputePhase(ready, total int32) multigresv1alpha1.Phase

ComputePhase determines the phase of a resource based on its readiness. This is a shared helper used by resources with simple replica counts.

func IsConditionTrue

func IsConditionTrue(conditions []metav1.Condition, condType string) bool

IsConditionTrue returns true if the named condition exists and has status True.

func IsCrashLooping

func IsCrashLooping(pod *corev1.Pod) bool

IsCrashLooping returns true if any container in the pod is unhealthy:

  • in CrashLoopBackOff, OOMKilled, or ImagePullBackOff waiting state, OR
  • terminated with repeated restarts (catches the gap between backoff restarts when the container is in Completed/Error state).

Both regular containers and init containers (native sidecars) are checked.

func SetCondition

func SetCondition(conditions *[]metav1.Condition, condition metav1.Condition)

SetCondition adds or updates a condition in the slice. When the status has not changed, the existing LastTransitionTime is preserved.

Types

type WorkloadPhaseInput

type WorkloadPhaseInput struct {
	Ready, Total       int32
	GenerationCurrent  int64
	GenerationObserved int64
	Pods               []corev1.Pod
	ComponentName      string
}

WorkloadPhaseInput describes the observed state of a workload for phase computation.

type WorkloadPhaseResult

type WorkloadPhaseResult struct {
	Phase   multigresv1alpha1.Phase
	Message string
}

WorkloadPhaseResult holds the computed phase and a human-readable message.

func ComputeWorkloadPhase

func ComputeWorkloadPhase(in WorkloadPhaseInput) WorkloadPhaseResult

ComputeWorkloadPhase determines phase from replica counts, pod health, and generation freshness. Degraded (crash-looping) takes priority over all other non-Healthy states.

Jump to

Keyboard shortcuts

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