utils

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventReasonDetectedUnhealthy  = "DetectedUnhealthy"
	EventReasonRemediationCreated = "RemediationCreated"
	EventReasonRemediationSkipped = "RemediationSkipped"
	EventReasonRemediationRemoved = "RemediationRemoved"
	EventReasonDisabled           = "Disabled"
	EventReasonEnabled            = "Enabled"
)
View Source
const (
	MachineNodeNameIndex = "machineNodeNameIndex"
)

Variables

View Source
var (
	// DefaultRemediationDuration is used for node lease calculations for remediations without configured timeout
	DefaultRemediationDuration = 10 * time.Minute
)
View Source
var MachineAnnotationNotFoundError = errors.New("machine annotation not found")

MachineAnnotationNotFoundError indicates that in GetMachineNsName the machine annotation wasn't found on the given node

Functions

func GetAllRemediationTemplates added in v0.7.0

func GetAllRemediationTemplates(healthCheck client.Object) []*v1.ObjectReference

GetAllRemediationTemplates returns a slice of all ObjectReferences used as RemedediationTemplate in the given NodeHealthCheck

func GetDeploymentNamespace

func GetDeploymentNamespace() (string, error)

GetDeploymentNamespace returns the Namespace this operator is deployed on.

func GetLogWithNHC added in v0.3.0

func GetLogWithNHC(log logr.Logger, nhc *v1alpha1.NodeHealthCheck) logr.Logger

GetLogWithNHC return a logger with NHC namespace and name

func GetMachineNamespaceName added in v0.7.0

func GetMachineNamespaceName(node *v1.Node) (namespace, name string, err error)

GetMachineNamespaceName returns machine namespace and name of the given Node. Returns MachineAnnotationNotFoundError in case the needed annotation doesn't exist on the given node

func GetNodeNameFromCR added in v0.9.0

func GetNodeNameFromCR(cr unstructured.Unstructured) string

GetNodeNameFromCR returns the node name from the given CR. If the CR has a nodeName annotation, it will return its value, otherwise it will return the CR name.

func GetRemediationDuration added in v0.7.0

func GetRemediationDuration(nhc *v1alpha1.NodeHealthCheck, remediationCR *unstructured.Unstructured) (currentRemediationDuration, previousRemediationsDuration time.Duration)

GetRemediationDuration returns the expected remediation duration for the given CR, and all previous used templates

func GetTemplateNameFromCR added in v0.9.0

func GetTemplateNameFromCR(cr unstructured.Unstructured) string

GetTemplateNameFromCR returns the template name from the given CR, if set.

func IsConditionFalseWithReason added in v0.11.0

func IsConditionFalseWithReason(conditions []metav1.Condition, conditionType string, reason string) bool

IsConditionFalseWithReason return true when the conditions contain a condition of given type and reason with status false, this isn't the logical opposite of IsConditionTrueWithReason because the condition is expected to be set with a false status.

func IsConditionSet added in v0.11.0

func IsConditionSet(conditions []metav1.Condition, conditionType string) bool

IsConditionSet return true when the conditions contain a condition of given type

func IsConditionTrue added in v0.3.0

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

IsConditionTrue returns true when the conditions contain a condition of given type with status true, regardless of reason

func IsConditionTrueWithReason added in v0.11.0

func IsConditionTrueWithReason(conditions []metav1.Condition, conditionType string, reason string) bool

IsConditionTrueWithReason return true when the conditions contain a condition of given type and reason with status true

func IsHealthyMHC added in v0.7.0

func IsHealthyMHC(unhealthyConditions []v1beta1.UnhealthyCondition, nodeConditions []corev1.NodeCondition, now time.Time) (bool, *time.Duration)

func IsHealthyNHC added in v0.7.0

func IsHealthyNHC(unhealthyConditions []remediationv1alpha1.UnhealthyCondition, nodeConditions []corev1.NodeCondition, now time.Time) (bool, *time.Duration)

func MHCByFeatureGateEventMapperFunc added in v0.7.0

func MHCByFeatureGateEventMapperFunc(c client.Client, logger logr.Logger, featureGates featuregates.Accessor) handler.MapFunc

MHCByFeatureGateEventMapperFunc return the FeatureGateEvent-to-NHC mapper function

func MHCByMachineMapperFunc added in v0.7.0

func MHCByMachineMapperFunc(c client.Client, logger logr.Logger, featureGates featuregates.Accessor) handler.MapFunc

MHCByMachineMapperFunc return the Machine-to-MHC mapper function

func MHCByNodeMapperFunc added in v0.7.0

func MHCByNodeMapperFunc(c client.Client, logger logr.Logger, featureGates featuregates.Accessor) handler.MapFunc

MHCByNodeMapperFunc return the Node-to-MHC mapper function

func MHCByRemediationTemplateCRMapperFunc added in v0.10.0

func MHCByRemediationTemplateCRMapperFunc(c client.Client, logger logr.Logger) handler.MapFunc

MHCByRemediationTemplateCRMapperFunc return the RemediationTemplateCR-to-MHC mapper function

func MinRequeueDuration added in v0.6.0

func MinRequeueDuration(old, new *time.Duration) *time.Duration

MinRequeueDuration returns the minimal valid requeue duration

func NHCByMHCEventMapperFunc added in v0.6.0

func NHCByMHCEventMapperFunc(c client.Client, logger logr.Logger) handler.MapFunc

NHCByMHCEventMapperFunc return the MHC-event-to-NHC mapper function

func NHCByNodeMapperFunc added in v0.3.0

func NHCByNodeMapperFunc(c client.Client, logger logr.Logger) handler.MapFunc

NHCByNodeMapperFunc return the Node-to-NHC mapper function

func NHCByRemediationTemplateCRMapperFunc added in v0.7.0

func NHCByRemediationTemplateCRMapperFunc(c client.Client, logger logr.Logger) handler.MapFunc

NHCByRemediationTemplateCRMapperFunc return the RemediationTemplateCR-to-NHC mapper function

func RemediationCRMapperFunc added in v0.10.0

func RemediationCRMapperFunc(logger logr.Logger, watchType WatchType) handler.MapFunc

RemediationCRMapperFunc return the RemediationCR-to-NHC/MHC mapper function

func SetMachineCondition added in v0.7.0

func SetMachineCondition(mhc *v1beta1.MachineHealthCheck, condition *v1beta1.Condition)

Types

type WatchType added in v0.10.0

type WatchType string

WatchType is used to differentiate watch CR logic between NHC and MHC.

const (
	NHC WatchType = "NHC"
	MHC WatchType = "MHC"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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