utils

package
v0.3.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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FenceAgentActionSucceededType is the condition type used to signal whether the Fence Agent action was succeeded successfully or not
	FenceAgentActionSucceededType = "FenceAgentActionSucceeded"
	// condition messages
	RemediationFinishedNodeNotFoundConditionMessage = "FAR CR name doesn't match a node name"
	RemediationInterruptedByNHCConditionMessage     = "Node Healthcheck timeout annotation has been set. Remediation has stopped"
	RemediationStartedConditionMessage              = "FAR CR was found, its name matches one of the cluster nodes, and a finalizer was set to the CR"
	FenceAgentSucceededConditionMessage             = "FAR taint was added and the fence agent command has been created and executed successfully"
	FenceAgentFailedConditionMessage                = "Fence agent command has failed"
	FenceAgentTimedOutConditionMessage              = "Time out occurred while executing the Fence agent command"
	RemediationFinishedSuccessfullyConditionMessage = "" /* 131-byte string literal not displayed */
)
View Source
const (
	// common events reason and message
	EventReasonRemediationStarted  = "RemediationStarted"
	EventMessageRemediationStarted = "Remediation started"

	// events reasons
	EventReasonCrNodeNotFound           = "NodeNotFound"
	EventReasonRemediationStoppedByNHC  = "RemediationStoppedByNHC"
	EventReasonAddFinalizer             = "AddFinalizer"
	EventReasonRemoveRemediationTaint   = "RemoveRemediationTaint"
	EventReasonRemoveFinalizer          = "RemoveFinalizer"
	EventReasonAddRemediationTaint      = "AddRemediationTaint"
	EventReasonFenceAgentExecuted       = "FenceAgentExecuted"
	EventReasonFenceAgentSucceeded      = "FenceAgentSucceeded"
	EventReasonDeleteResources          = "DeleteResources"
	EventReasonNodeRemediationCompleted = "NodeRemediationCompleted"

	// events messages
	EventMessageCrNodeNotFound           = "CR name doesn't match a node name"
	EventMessageRemediationStoppedByNHC  = "Remediation was stopped by the Node Healthcheck Operator"
	EventMessageAddFinalizer             = "Finalizer was added"
	EventMessageRemoveRemediationTaint   = "Remediation taint was removed"
	EventMessageRemoveFinalizer          = "Finalizer was removed"
	EventMessageAddRemediationTaint      = "Remediation taint was added"
	EventMessageFenceAgentExecuted       = "Fence agent was executed"
	EventMessageFenceAgentSucceeded      = "Fence agent was succeeded"
	EventMessageDeleteResources          = "Manually delete pods from the unhealthy node"
	EventMessageNodeRemediationCompleted = "Unhealthy node remediation was completed"
)

Variables

This section is empty.

Functions

func AppendTaint

func AppendTaint(r client.Client, nodeName string) (bool, error)

AppendTaint appends new taint to the taint list when it is not present. It returns bool if a taint was appended, and an error if it fails in the process

func CreateRemediationTaint added in v0.3.0

func CreateRemediationTaint() corev1.Taint

CreateRemediationTaint returns a remediation NoExeucte taint

func GetDeploymentNamespace

func GetDeploymentNamespace() (string, error)

GetDeploymentNamespace returns the Namespace this operator is deployed/installed on.

func GetFenceAgentsRemediationPod

func GetFenceAgentsRemediationPod(r client.Reader) (*corev1.Pod, error)

GetFenceAgentsRemediationPod fetches the first running pod that matches to FAR's label and namespace The pod should be on running state since when we taint and reboot a node which had FAR, then that pod will be restarted on a different node, This results with an old pod which is about to die and new pod is already running and we want to return the running pod

func GetNode

func GetNode(nodeRole, nodeName string) *corev1.Node

GetNode returns a node object with the name nodeName based on the nodeType input used for making new node object for test and have a unique resourceVersion

func GetNodeWithName

func GetNodeWithName(r client.Reader, nodeName string) (*corev1.Node, error)

GetNodeWithName returns a node with a name nodeName, or an error if it can't be found

func RemoveTaint

func RemoveTaint(r client.Client, nodeName string) error

RemoveTaint removes taint from the taint list when it is existed, and returns error if it fails in the process

func TaintExists

func TaintExists(taints []corev1.Taint, taintToFind *corev1.Taint) bool

TaintExists checks if the given taint exists in list of taints. Returns true if exists false otherwise.

func UpdateConditions added in v0.3.0

func UpdateConditions(reason ConditionsChangeReason, far *v1alpha1.FenceAgentsRemediation, log logr.Logger)

updateConditions updates the status conditions of a FenceAgentsRemediation object based on the provided ConditionsChangeReason. return an error if an unknown ConditionsChangeReason is provided

Types

type ConditionsChangeReason added in v0.3.0

type ConditionsChangeReason string

ConditionsChangeReason represents the reason of updating the some or all the conditions

const (
	// RemediationFinishedNodeNotFound - CR was found but its name doesn't match any node
	RemediationFinishedNodeNotFound ConditionsChangeReason = "RemediationFinishedNodeNotFound"
	// RemediationInterruptedByNHC - Remediation was interrupted by NHC timeout annotation
	RemediationInterruptedByNHC ConditionsChangeReason = "RemediationInterruptedByNHC"
	// RemediationStarted - CR was found, its name matches a node, and a finalizer was set
	RemediationStarted ConditionsChangeReason = "RemediationStarted"
	// FenceAgentSucceeded - FAR taint was added, fence agent command has been created and executed successfully
	FenceAgentSucceeded ConditionsChangeReason = "FenceAgentSucceeded"
	// FenceAgentFailed - Fence agent command has been created but failed to execute
	FenceAgentFailed ConditionsChangeReason = "FenceAgentFailed"
	// FenceAgentTimedOut - Fence agent command has been created but timed out
	FenceAgentTimedOut ConditionsChangeReason = "FenceAgentTimedOut"
	// RemediationFinishedSuccessfully - The unhealthy node was fully remediated/fenced (it was tainted, fenced by FA and all of its resources have been deleted)
	RemediationFinishedSuccessfully ConditionsChangeReason = "RemediationFinishedSuccessfully"
)

Jump to

Keyboard shortcuts

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