state

package
v0.29.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: Apache-2.0 Imports: 28 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) Consolidated added in v0.24.0

func (c *Cluster) Consolidated() bool

Consolidated returns whether the current cluster state has been observed for consolidation. If consolidation can't occur and the state hasn't changed, there is no point in re-attempting consolidation. This allows reducing overall CPU utilization by pausing consolidation when the cluster is in a static state.

func (*Cluster) DeleteDaemonSet added in v0.25.0

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

func (*Cluster) DeleteMachine added in v0.24.0

func (c *Cluster) DeleteMachine(name string)

func (*Cluster) DeleteNode

func (c *Cluster) DeleteNode(name string)

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(name 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(names ...string)

MarkForDeletion marks the node as pending deletion in the internal cluster 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, name 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) SetConsolidated added in v0.24.0

func (c *Cluster) SetConsolidated(consolidated bool)

SetConsolidated updates based on the following conditions:

  1. consolidated is TRUE: Updates the state to record that we have viewed this cluster state at this time
  2. consolidated is FALSE: Resets the value to mark that we haven't currently viewed this state or the state is in flux

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(names ...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) UpdateMachine added in v0.24.0

func (c *Cluster) UpdateMachine(machine *v1alpha5.Machine)

func (*Cluster) UpdateNode

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

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
	Machine *v1alpha5.Machine
	// 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 Node.

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) 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) 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) Owned added in v0.27.1

func (in *StateNode) Owned() bool

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) 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) VolumeLimits added in v0.27.1

func (in *StateNode) VolumeLimits() scheduling.VolumeCount

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