Documentation
¶
Overview ¶
Package machineutils contains the consts and global vaariables for machine operation
Index ¶
- Constants
- Variables
- func IsMachineActive(p *v1alpha1.Machine) bool
- func IsMachineFailed(p *v1alpha1.Machine) bool
- func IsMachineFailedOrTerminating(machine *v1alpha1.Machine) bool
- func IsMachinePreservationExpired(m *v1alpha1.Machine) bool
- func IsMachineTriggeredForDeletion(m *v1alpha1.Machine) bool
- func UpdateMachineWithRetries(ctx context.Context, machineClient v1alpha1client.MachineInterface, ...) (*v1alpha1.Machine, error)
- type RetryPeriod
Constants ¶
const ( // GetVMStatus sets machine status to terminating and specifies next step as getting VMs GetVMStatus = "Set machine status to termination. Now, getting VM Status" // InstanceInitialization is a step that represents initialization of a VM instance (post-creation). InstanceInitialization = "Initialize VM Instance" // InitiateDrain specifies next step as initiate node drain InitiateDrain = "Initiate node drain" // NodeReadyForUpdate specifies next step as node ready for update. NodeReadyForUpdate = "Node drain successful. Node is ready for update" // DelVolumesAttachments specifies next step as deleting volume attachments DelVolumesAttachments = "Delete Volume Attachments" // InitiateVMDeletion specifies next step as initiate VM deletion InitiateVMDeletion = "Initiate VM deletion" // InitiateNodeDeletion specifies next step as node object deletion InitiateNodeDeletion = "Initiate node object deletion" // InitiateFinalizerRemoval specifies next step as machine finalizer removal InitiateFinalizerRemoval = "Initiate machine object finalizer removal" // LastAppliedALTAnnotation contains the last configuration of annotations, labels & taints applied on the node object LastAppliedALTAnnotation = "node.machine.sapcloud.io/last-applied-anno-labels-taints" // LastAppliedVirtualCapacityAnnotation contains the last configuration of MachineClass.NodeTemplate.VirtualCapacity applied on the node object LastAppliedVirtualCapacityAnnotation = "node.machine.sapcloud.io/last-applied-virtual-capacity" // MachinePriority is the annotation used to specify priority // associated with a machine while deleting it. The less its // priority the more likely it is to be deleted first // Default priority for a machine is set to 3 MachinePriority = "machinepriority.machine.sapcloud.io" // MachineClassKind is used to identify the machineClassKind for generic machineClasses MachineClassKind = "MachineClass" // NotManagedByMCM annotation helps in identifying the nodes which are not handled by MCM NotManagedByMCM = "node.machine.sapcloud.io/not-managed-by-mcm" // TriggerDeletionByMCM is the annotation set on the MachineDeployment by the CA-MCM cloud provider. It contains the machine names // for which deletion should be triggered along with the time when CA decided to scale-down those machines. // Expected format for this annotation value is [M1~T1,M2~T2,...] TriggerDeletionByMCM = "node.machine.sapcloud.io/trigger-deletion-by-mcm" // MarkedForDeletionTime is the annotation used to specify the time when machine was marked for deletion. // This is used by MCS to delete the machines which were marked for deletion before the MCS saw the replica change. MarkedForDeletionTime = "machine.sapcloud.io/marked-for-deletion-time" // LastDeploymentReplicaChangeByScalerTime is the annotation used to specify the time when machineDeployment replica change was triggered by a scaler. LastDeploymentReplicaChangeByScalerTime = "machine.sapcloud.io/last-deployment-replica-change-by-scaler-time" // NodeUnhealthy is a node termination reason for failed machines NodeUnhealthy = "Unhealthy" // NodeScaledDown is a node termination reason for healthy deleted machines NodeScaledDown = "ScaleDown" // NodeTerminationCondition describes nodes that are terminating NodeTerminationCondition v1.NodeConditionType = "Terminating" // TaintNodeCriticalComponentsNotReady is the name of a gardener taint // indicating that a node is not yet ready to have user workload scheduled TaintNodeCriticalComponentsNotReady = "node.gardener.cloud/critical-components-not-ready" // MachineLabelKey defines the labels which contains the name of the machine of a node MachineLabelKey = "node.gardener.cloud/machine-name" // LabelKeyMachineSetScaleUpDisabled is the label key that indicates scaling up of the machine set is disabled. LabelKeyMachineSetScaleUpDisabled = "node.machine.sapcloud.io/scale-up-disabled" // PreserveMachineAnnotationKey is the annotation used to explicitly request that a Machine be preserved PreserveMachineAnnotationKey = "node.machine.sapcloud.io/preserve" // LastAppliedNodePreserveValueAnnotationKey is the annotation used to store the last preserve value applied by MCM LastAppliedNodePreserveValueAnnotationKey = "node.machine.sapcloud.io/last-applied-node-preserve-value" // PreserveMachineAnnotationValueNow is the annotation value used to explicitly request that // a Machine be preserved immediately, irrespective of its current phase, and its phase is not changed // on preservation PreserveMachineAnnotationValueNow = "now" // PreserveMachineAnnotationValueWhenFailed is the annotation value used to explicitly request that // a Machine be preserved if and when it enters Failed phase PreserveMachineAnnotationValueWhenFailed = "when-failed" // PreserveMachineAnnotationValuePreservedByMCM is the annotation value used by the machineset controller to // indicate to the machine controller that the machine must be auto-preserved. // The AutoPreserveFailedMachineMax, set on the MCD, is enforced based on the number of machines annotated with this value. PreserveMachineAnnotationValuePreservedByMCM = "auto-preserved" // PreserveMachineAnnotationValueFalse is the annotation value used to // 1) indicate to MCM that a machine must not be auto-preserved on failure // and, 2) to stop auto-preservation of a machine that is already auto-preserved by MCM. PreserveMachineAnnotationValueFalse = "false" )
Variables ¶
var AllowedPreserveAnnotationValues = sets.New(PreserveMachineAnnotationValueNow, PreserveMachineAnnotationValueWhenFailed, PreserveMachineAnnotationValuePreservedByMCM, PreserveMachineAnnotationValueFalse, "")
AllowedPreserveAnnotationValues contains the allowed values for the preserve annotation
var EssentialTaints = []string{TaintNodeCriticalComponentsNotReady}
EssentialTaints are taints on node object which if added/removed, require an immediate reconcile by machine controller TODO: update this when taints for ALT updation and PostCreate operations is introduced.
var PreventAutoPreserveAnnotationValues = sets.New(PreserveMachineAnnotationValueNow, PreserveMachineAnnotationValueWhenFailed, PreserveMachineAnnotationValuePreservedByMCM, PreserveMachineAnnotationValueFalse)
PreventAutoPreserveAnnotationValues contains the values to check if a machine is already annotated for preservation, in which case it should not be auto-preserved.
Functions ¶
func IsMachineActive ¶ added in v0.57.1
IsMachineActive checks if machine was active
func IsMachineFailed ¶ added in v0.57.1
IsMachineFailed checks if machine has failed
func IsMachineFailedOrTerminating ¶ added in v0.56.0
IsMachineFailedOrTerminating returns true if machine is Failed or already being Terminated.
func IsMachinePreservationExpired ¶ added in v0.62.0
IsMachinePreservationExpired checks if the preserve expiry time has passed for a machine
func IsMachineTriggeredForDeletion ¶ added in v0.57.1
IsMachineTriggeredForDeletion checks if machine was triggered for deletion
func UpdateMachineWithRetries ¶ added in v0.62.0
func UpdateMachineWithRetries(ctx context.Context, machineClient v1alpha1client.MachineInterface, machineLister v1alpha1listers.MachineLister, namespace, name string, applyUpdate updateMachineFunc) (*v1alpha1.Machine, error)
UpdateMachineWithRetries updates a machine with given applyUpdate function. Note that machine not found error is ignored.
Types ¶
type RetryPeriod ¶ added in v0.35.0
RetryPeriod is an alias for specifying the retry period
const ( // ConflictRetry tells the controller to retry quickly - 200 milliseconds ConflictRetry RetryPeriod = RetryPeriod(200 * time.Millisecond) // ShortRetry tells the controller to retry after a short duration - 5 seconds ShortRetry RetryPeriod = RetryPeriod(5 * time.Second) // MediumRetry tells the controller to retry after a medium duration - 3 minutes MediumRetry RetryPeriod = RetryPeriod(3 * time.Minute) // LongRetry tells the controller to retry after a long duration - 10 minutes LongRetry RetryPeriod = RetryPeriod(10 * time.Minute) )
These are the valid values for RetryPeriod