clusterstate

package
v0.0.0-...-386b7fa Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxNodeStartupTime is the maximum time from the moment the node is registered to the time the node is ready.
	MaxNodeStartupTime = 15 * time.Minute

	// MaxStatusSettingDelayAfterCreation is the maximum time for node to set its initial status after the
	// node is registered.
	MaxStatusSettingDelayAfterCreation = 2 * time.Minute

	// MaxNodeGroupBackoffDuration is the maximum backoff duration for a NodeGroup after new nodes failed to start.
	MaxNodeGroupBackoffDuration = 30 * time.Minute

	// InitialNodeGroupBackoffDuration is the duration of first backoff after a new node failed to start.
	InitialNodeGroupBackoffDuration = 5 * time.Minute

	// NodeGroupBackoffResetTimeout is the time after last failed scale-up when the backoff duration is reset.
	NodeGroupBackoffResetTimeout = 3 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptableRange

type AcceptableRange struct {
	// MinNodes is the minimum number of nodes in the group.
	MinNodes int
	// MaxNodes is the maximum number of nodes in the group.
	MaxNodes int
	// CurrentTarget is the current target size of the group.
	CurrentTarget int
}

AcceptableRange contains information about acceptable size of a node group.

type ClusterStateRegistry

type ClusterStateRegistry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

ClusterStateRegistry is a structure to keep track the current state of the cluster.

func NewClusterStateRegistry

func NewClusterStateRegistry(cloudProvider cloudprovider.CloudProvider, config ClusterStateRegistryConfig, logRecorder *utils.LogEventRecorder, backoff backoff.Backoff) *ClusterStateRegistry

NewClusterStateRegistry creates new ClusterStateRegistry.

func (*ClusterStateRegistry) GetClusterReadiness

func (csr *ClusterStateRegistry) GetClusterReadiness() Readiness

GetClusterReadiness returns current readiness stats of cluster

func (*ClusterStateRegistry) GetClusterSize

func (csr *ClusterStateRegistry) GetClusterSize() (currentSize, targetSize int)

GetClusterSize calculates and returns cluster's current size and target size. The current size is the actual number of nodes provisioned in Kubernetes, the target size is the number of nodes the CA wants.

func (*ClusterStateRegistry) GetCreatedNodesWithOutOfResourcesErrors

func (csr *ClusterStateRegistry) GetCreatedNodesWithOutOfResourcesErrors() []*apiv1.Node

GetCreatedNodesWithOutOfResourcesErrors returns list of nodes being created which reported create error of "out of resources" class.

func (*ClusterStateRegistry) GetIncorrectNodeGroupSize

func (csr *ClusterStateRegistry) GetIncorrectNodeGroupSize(nodeGroupName string) *IncorrectNodeGroupSize

GetIncorrectNodeGroupSize gets IncorrectNodeGroupSizeInformation for the given node group.

func (*ClusterStateRegistry) GetStatus

GetStatus returns ClusterAutoscalerStatus with the current cluster autoscaler status.

func (*ClusterStateRegistry) GetUnregisteredNodes

func (csr *ClusterStateRegistry) GetUnregisteredNodes() []UnregisteredNode

GetUnregisteredNodes returns a list of all unregistered nodes.

func (*ClusterStateRegistry) GetUpcomingNodes

func (csr *ClusterStateRegistry) GetUpcomingNodes() map[string]int

GetUpcomingNodes returns how many new nodes will be added shortly to the node groups or should become ready soon. The function may overestimate the number of nodes.

func (*ClusterStateRegistry) IsClusterHealthy

func (csr *ClusterStateRegistry) IsClusterHealthy() bool

IsClusterHealthy returns true if the cluster health is within the acceptable limits

func (*ClusterStateRegistry) IsNodeGroupAtTargetSize

func (csr *ClusterStateRegistry) IsNodeGroupAtTargetSize(nodeGroupName string) bool

IsNodeGroupAtTargetSize returns true if the number of nodes provisioned in the group is equal to the target number of nodes.

func (*ClusterStateRegistry) IsNodeGroupHealthy

func (csr *ClusterStateRegistry) IsNodeGroupHealthy(nodeGroupName string) bool

IsNodeGroupHealthy returns true if the node group health is within the acceptable limits

func (*ClusterStateRegistry) IsNodeGroupSafeToScaleUp

func (csr *ClusterStateRegistry) IsNodeGroupSafeToScaleUp(nodeGroup cloudprovider.NodeGroup, now time.Time) bool

IsNodeGroupSafeToScaleUp returns true if node group can be scaled up now.

func (*ClusterStateRegistry) IsNodeGroupScalingUp

func (csr *ClusterStateRegistry) IsNodeGroupScalingUp(nodeGroupName string) bool

IsNodeGroupScalingUp returns true if the node group is currently scaling up.

func (*ClusterStateRegistry) Recalculate

func (csr *ClusterStateRegistry) Recalculate()

Recalculate cluster state after scale-ups or scale-downs were registered.

func (*ClusterStateRegistry) RegisterFailedScaleUp

func (csr *ClusterStateRegistry) RegisterFailedScaleUp(nodeGroup cloudprovider.NodeGroup, reason metrics.FailedScaleUpReason, currentTime time.Time)

RegisterFailedScaleUp should be called after getting error from cloudprovider when trying to scale-up node group. It will mark this group as not safe to autoscale for some time.

func (*ClusterStateRegistry) RegisterOrUpdateScaleUp

func (csr *ClusterStateRegistry) RegisterOrUpdateScaleUp(nodeGroup cloudprovider.NodeGroup, delta int, currentTime time.Time)

RegisterOrUpdateScaleUp registers scale-up for give node group or changes requested node increase count. If delta is positive then number of new nodes requested is increased; Time and expectedAddTime are reset. If delta is negative the number of new nodes requested is decreased; Time and expectedAddTime are left intact.

func (*ClusterStateRegistry) RegisterScaleDown

func (csr *ClusterStateRegistry) RegisterScaleDown(request *ScaleDownRequest)

RegisterScaleDown registers node scale down.

func (*ClusterStateRegistry) UpdateNodes

func (csr *ClusterStateRegistry) UpdateNodes(nodes []*apiv1.Node, nodeInfosForGroups map[string]*schedulernodeinfo.NodeInfo, currentTime time.Time) error

UpdateNodes updates the state of the nodes in the ClusterStateRegistry and recalculates the stats

func (*ClusterStateRegistry) UpdateScaleDownCandidates

func (csr *ClusterStateRegistry) UpdateScaleDownCandidates(nodes []*apiv1.Node, now time.Time)

UpdateScaleDownCandidates updates scale down candidates

type ClusterStateRegistryConfig

type ClusterStateRegistryConfig struct {
	// Maximum percentage of unready nodes in total, if the number of unready nodes is higher than OkTotalUnreadyCount.
	MaxTotalUnreadyPercentage float64
	// Minimum number of nodes that must be unready for MaxTotalUnreadyPercentage to apply.
	// This is to ensure that in very small clusters (e.g. 2 nodes) a single node's failure doesn't disable autoscaling.
	OkTotalUnreadyCount int
	//  Maximum time CA waits for node to be provisioned
	MaxNodeProvisionTime time.Duration
}

ClusterStateRegistryConfig contains configuration information for ClusterStateRegistry.

type IncorrectNodeGroupSize

type IncorrectNodeGroupSize struct {
	// ExpectedSize is the size of the node group measured on the cloud provider side.
	ExpectedSize int
	// CurrentSize is the size of the node group measured on the kubernetes side.
	CurrentSize int
	// FirstObserved is the time when the given difference occurred.
	FirstObserved time.Time
}

IncorrectNodeGroupSize contains information about how much the current size of the node group differs from the expected size. Prolonged, stable mismatch is an indication of quota or startup issues.

type Readiness

type Readiness struct {
	// Number of ready nodes.
	Ready int
	// Number of unready nodes that broke down after they started.
	Unready int
	// Number of nodes that are being currently deleted. They exist in K8S but
	// are not included in NodeGroup.TargetSize().
	Deleted int
	// Number of nodes that failed to start within a reasonable limit.
	LongNotStarted int
	// Number of nodes that are not yet fully started.
	NotStarted int
	// Number of all registered nodes in the group (ready/unready/deleted/etc).
	Registered int
	// Number of nodes that failed to register within a reasonable limit.
	LongUnregistered int
	// Number of nodes that haven't yet registered.
	Unregistered int
	// Time when the readiness was measured.
	Time time.Time
}

Readiness contains readiness information about a group of nodes.

type ScaleDownRequest

type ScaleDownRequest struct {
	// NodeName is the name of the node to be deleted.
	NodeName string
	// NodeGroup is the node group of the deleted node.
	NodeGroup cloudprovider.NodeGroup
	// Time is the time when the node deletion was requested.
	Time time.Time
	// ExpectedDeleteTime is the time when the node is expected to be deleted.
	ExpectedDeleteTime time.Time
}

ScaleDownRequest contains information about the requested node deletion.

type ScaleUpRequest

type ScaleUpRequest struct {
	// NodeGroup is the node group to be scaled up.
	NodeGroup cloudprovider.NodeGroup
	// Time is the time when the request was submitted.
	Time time.Time
	// ExpectedAddTime is the time at which the request should be fulfilled.
	ExpectedAddTime time.Time
	// How much the node group is increased.
	Increase int
}

ScaleUpRequest contains information about the requested node group scale up.

type UnregisteredNode

type UnregisteredNode struct {
	// Node is a dummy node that contains only the name of the node.
	Node *apiv1.Node
	// UnregisteredSince is the time when the node was first spotted.
	UnregisteredSince time.Time
}

UnregisteredNode contains information about nodes that are present on the cluster provider side but failed to register in Kubernetes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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