utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventReasonDetectedUnhealthy  = "DetectedUnhealthy"
	EventReasonRemediationCreated = "RemediationCreated"
	EventReasonRemediationSkipped = "RemediationSkipped"
	EventReasonRemediationRemoved = "RemediationRemoved"
	EventReasonDisabled           = "Disabled"
	EventReasonEnabled            = "Enabled"
)
View Source
const (
	// MHCPausedAnnotation is an annotation that can be applied to MachineHealthCheck objects to prevent the MHC
	// controller from processing it.
	MHCPausedAnnotation = "cluster.x-k8s.io/paused"
)
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 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 HasMHCPausedAnnotation added in v0.7.0

func HasMHCPausedAnnotation(o metav1.Object) bool

HasMHCPausedAnnotation returns true if the object has the MHC `paused` annotation.

func IsConditionTrue added in v0.3.0

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

IsConditionTrue 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 IsOnOpenshift

func IsOnOpenshift(config *rest.Config) (bool, error)

IsOnOpenshift returns true if the cluster has the openshift config group

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 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 NHCByRemediationCRMapperFunc added in v0.5.0

func NHCByRemediationCRMapperFunc(logger logr.Logger) handler.MapFunc

NHCByRemediationCRMapperFunc return the RemediationCR-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 SetMachineCondition added in v0.7.0

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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