state

package
v0.31.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster maintains cluster state that is often needed but expensive to compute.

func NewCluster

func NewCluster(clk clock.Clock, client client.Client, cp cloudprovider.CloudProvider) *Cluster

func (*Cluster) ConsolidationState added in v0.30.0

func (c *Cluster) ConsolidationState() time.Time

ConsolidationState returns a timestamp of the last time that the cluster state with respect to consolidation changed. If nothing changes, this timestamp resets after five minutes to force watchers that use this to defer work to occasionally revalidate that nothing external (e.g. an instance type becoming available) has changed that now makes it possible for them to operate. Time was chosen as the type here as it allows comparisons using the built-in monotonic clock.

func (*Cluster) DeleteDaemonSet added in v0.25.0

func (c *Cluster) DeleteDaemonSet(key types.NamespacedName)

func (*Cluster) DeleteNode

func (c *Cluster) DeleteNode(name string)

func (*Cluster) DeleteNodeClaim added in v0.30.0

func (c *Cluster) DeleteNodeClaim(key nodeclaimutil.Key)

func (*Cluster) DeletePod

func (c *Cluster) DeletePod(podKey types.NamespacedName)

func (*Cluster) ForEachNode

func (c *Cluster) ForEachNode(f func(n *StateNode) bool)

ForEachNode calls the supplied function once per node object that is being tracked. It is not safe to store the state.StateNode object, it should be only accessed from within the function provided to this method.

func (*Cluster) ForPodsWithAntiAffinity

func (c *Cluster) ForPodsWithAntiAffinity(fn func(p *v1.Pod, n *v1.Node) bool)

ForPodsWithAntiAffinity calls the supplied function once for each pod with required anti affinity terms that is currently bound to a node. The pod returned may not be up-to-date with respect to status, however since the anti-affinity terms can't be modified, they will be correct.

func (*Cluster) GetDaemonSetPod added in v0.25.0

func (c *Cluster) GetDaemonSetPod(daemonset *appsv1.DaemonSet) *v1.Pod

func (*Cluster) IsNodeNominated

func (c *Cluster) IsNodeNominated(providerID string) bool

IsNodeNominated returns true if the given node was expected to have a pod bound to it during a recent scheduling batch

func (*Cluster) MarkForDeletion

func (c *Cluster) MarkForDeletion(providerIDs ...string)

MarkForDeletion marks the node as pending deletion in the internal cluster state

func (*Cluster) MarkUnconsolidated added in v0.30.0

func (c *Cluster) MarkUnconsolidated() time.Time

MarkUnconsolidated marks the cluster state as being unconsolidated. This should be called in any situation where something in the cluster has changed such that the cluster may have moved from a non-consolidatable to a consolidatable state.

func (*Cluster) Nodes added in v0.24.0

func (c *Cluster) Nodes() StateNodes

Nodes creates a DeepCopy of all state nodes. NOTE: This is very inefficient so this should only be used when DeepCopying is absolutely necessary

func (*Cluster) NominateNodeForPod

func (c *Cluster) NominateNodeForPod(ctx context.Context, providerID string)

NominateNodeForPod records that a node was the target of a pending pod during a scheduling batch

func (*Cluster) Reset

func (c *Cluster) Reset()

Reset the cluster state for unit testing

func (*Cluster) Synced added in v0.24.0

func (c *Cluster) Synced(ctx context.Context) bool

Synced validates that the Machines and the Nodes that are stored in the apiserver have the same representation in the cluster state. This is to ensure that our view of the cluster is as close to correct as it can be when we begin to perform operations utilizing the cluster state as our source of truth

func (*Cluster) UnmarkForDeletion

func (c *Cluster) UnmarkForDeletion(providerIDs ...string)

UnmarkForDeletion removes the marking on the node as a node the controller intends to delete

func (*Cluster) UpdateDaemonSet added in v0.25.0

func (c *Cluster) UpdateDaemonSet(ctx context.Context, daemonset *appsv1.DaemonSet) error

func (*Cluster) UpdateNode

func (c *Cluster) UpdateNode(ctx context.Context, node *v1.Node) error

func (*Cluster) UpdateNodeClaim added in v0.30.0

func (c *Cluster) UpdateNodeClaim(nodeClaim *v1beta1.NodeClaim)

func (*Cluster) UpdatePod

func (c *Cluster) UpdatePod(ctx context.Context, pod *v1.Pod) error

type StateNode added in v0.27.1

type StateNode struct {
	Node      *v1.Node
	NodeClaim *v1beta1.NodeClaim
	// contains filtered or unexported fields
}

StateNode is a cached version of a node in the cluster that maintains state which is expensive to compute every time it's needed. This currently contains node utilization across all the allocatable resources, but will soon be used to compute topology information. +k8s:deepcopy-gen=true nolint: revive

func NewNode added in v0.24.0

func NewNode() *StateNode

func (*StateNode) Allocatable added in v0.27.1

func (in *StateNode) Allocatable() v1.ResourceList

func (*StateNode) Annotations added in v0.27.1

func (in *StateNode) Annotations() map[string]string

func (*StateNode) Available added in v0.27.1

func (in *StateNode) Available() v1.ResourceList

Available is allocatable minus anything allocated to pods.

func (*StateNode) Capacity added in v0.27.1

func (in *StateNode) Capacity() v1.ResourceList

func (*StateNode) DaemonSetLimits added in v0.27.1

func (in *StateNode) DaemonSetLimits() v1.ResourceList

func (*StateNode) DaemonSetRequests added in v0.27.1

func (in *StateNode) DaemonSetRequests() v1.ResourceList

func (*StateNode) DeepCopy added in v0.27.1

func (in *StateNode) DeepCopy() *StateNode

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StateNode.

func (*StateNode) DeepCopyInto added in v0.27.1

func (in *StateNode) DeepCopyInto(out *StateNode)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*StateNode) GetLabels added in v0.30.0

func (in *StateNode) GetLabels() map[string]string

GetLabels exists to conform to the GetLabels() function on the metav1.Object interface

func (*StateNode) HostName added in v0.27.1

func (in *StateNode) HostName() string

func (*StateNode) HostPortUsage added in v0.27.1

func (in *StateNode) HostPortUsage() *scheduling.HostPortUsage

func (*StateNode) Initialized added in v0.27.1

func (in *StateNode) Initialized() bool

func (*StateNode) Labels added in v0.27.1

func (in *StateNode) Labels() map[string]string

func (*StateNode) Managed added in v0.30.0

func (in *StateNode) Managed() bool

func (*StateNode) MarkedForDeletion added in v0.27.1

func (in *StateNode) MarkedForDeletion() bool

func (*StateNode) Name added in v0.27.1

func (in *StateNode) Name() string

func (*StateNode) Nominate added in v0.27.1

func (in *StateNode) Nominate(ctx context.Context)

func (*StateNode) Nominated added in v0.27.1

func (in *StateNode) Nominated() bool

func (*StateNode) OwnerKey added in v0.30.0

func (in *StateNode) OwnerKey() nodepoolutil.Key

func (*StateNode) PodLimits added in v0.27.1

func (in *StateNode) PodLimits() v1.ResourceList

func (*StateNode) PodRequests added in v0.27.1

func (in *StateNode) PodRequests() v1.ResourceList

func (*StateNode) Pods added in v0.27.1

func (in *StateNode) Pods(ctx context.Context, c client.Client) ([]*v1.Pod, error)

Pods gets the pods assigned to the Node based on the kubernetes api-server bindings

func (*StateNode) ProviderID added in v0.30.0

func (in *StateNode) ProviderID() string

ProviderID is the key that is used to map this StateNode If the Node and NodeClaim have a providerID, this should map to a real providerID If the Node does not have a providerID, this will map to the node name

func (*StateNode) Registered added in v0.29.1

func (in *StateNode) Registered() bool

func (*StateNode) Taints added in v0.27.1

func (in *StateNode) Taints() []v1.Taint

func (*StateNode) VolumeUsage added in v0.27.1

func (in *StateNode) VolumeUsage() *scheduling.VolumeUsage

type StateNodes added in v0.27.1

type StateNodes []*StateNode

StateNodes is a typed version of a list of *Node nolint: revive

func (StateNodes) Active added in v0.27.1

func (n StateNodes) Active() StateNodes

Active filters StateNodes that are not in a MarkedForDeletion state

func (StateNodes) Deleting added in v0.27.1

func (n StateNodes) Deleting() StateNodes

Deleting filters StateNodes that are in a MarkedForDeletion state

func (StateNodes) Pods added in v0.27.1

func (n StateNodes) Pods(ctx context.Context, c client.Client) ([]*v1.Pod, error)

Pods gets the pods assigned to all StateNodes based on the kubernetes api-server bindings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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