deprovisioning

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPodEvictionCost

func GetPodEvictionCost(ctx context.Context, p *v1.Pod) float64

GetPodEvictionCost returns the disruption cost computed for evicting the given pod.

func PodsPreventEviction

func PodsPreventEviction(pods []*v1.Pod) (string, bool)

PodsPreventEviction returns true if there are pods that would prevent eviction

Types

type CandidateFilter

type CandidateFilter func(context.Context, *state.Node, *v1alpha5.Provisioner, []*v1.Pod) bool

type CandidateNode

type CandidateNode struct {
	*v1.Node
	// contains filtered or unexported fields
}

CandidateNode is a node that we are considering for deprovisioning along with extra information to be used in making that determination

type Command

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

func (Command) String

func (o Command) String() string

type Controller

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

Controller is the deprovisioning controller.

func NewController

func NewController(clk clock.Clock, kubeClient client.Client, provisioner *provisioning.Provisioner,
	cp cloudprovider.CloudProvider, recorder events.Recorder, cluster *state.Cluster) *Controller

func (*Controller) Builder

func (*Controller) Name

func (c *Controller) Name() string

func (*Controller) ProcessCluster

func (c *Controller) ProcessCluster(ctx context.Context) (Result, error)

ProcessCluster is exposed for unit testing purposes ProcessCluster loops through implemented deprovisioners

func (*Controller) Reconcile

func (c *Controller) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error)

type Deprovisioner

type Deprovisioner interface {
	ShouldDeprovision(context.Context, *state.Node, *v1alpha5.Provisioner, []*v1.Pod) bool
	ComputeCommand(context.Context, ...CandidateNode) (Command, error)
	String() string
}

type Drift

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

Drift is a subreconciler that deletes empty nodes. Drift will respect TTLSecondsAfterEmpty

func NewDrift

func NewDrift(kubeClient client.Client, cluster *state.Cluster, provisioner *provisioning.Provisioner) *Drift

func (*Drift) ComputeCommand

func (d *Drift) ComputeCommand(ctx context.Context, candidates ...CandidateNode) (Command, error)

ComputeCommand generates a deprovisioning command given deprovisionable nodes

func (*Drift) ShouldDeprovision

func (d *Drift) ShouldDeprovision(ctx context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, nodePods []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*Drift) String

func (d *Drift) String() string

String is the string representation of the deprovisioner

type Emptiness

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

Emptiness is a subreconciler that deletes empty nodes. Emptiness will respect TTLSecondsAfterEmpty

func NewEmptiness

func NewEmptiness(clk clock.Clock, kubeClient client.Client, cluster *state.Cluster) *Emptiness

func (*Emptiness) ComputeCommand

func (e *Emptiness) ComputeCommand(_ context.Context, nodes ...CandidateNode) (Command, error)

ComputeCommand generates a deprovisioning command given deprovisionable nodes

func (*Emptiness) ShouldDeprovision

func (e *Emptiness) ShouldDeprovision(ctx context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, nodePods []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*Emptiness) String

func (e *Emptiness) String() string

string is the string representation of the deprovisioner

type EmptyNodeConsolidation

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

EmptyNodeConsolidation is the consolidation controller that performs multi-node consolidation of entirely empty nodes

func NewEmptyNodeConsolidation

func NewEmptyNodeConsolidation(clk clock.Clock, cluster *state.Cluster, kubeClient client.Client,
	provisioner *provisioning.Provisioner, cp cloudprovider.CloudProvider, reporter *Reporter) *EmptyNodeConsolidation

func (*EmptyNodeConsolidation) ComputeCommand

func (c *EmptyNodeConsolidation) ComputeCommand(ctx context.Context, candidates ...CandidateNode) (Command, error)

ComputeCommand generates a deprovisioning command given deprovisionable nodes

func (*EmptyNodeConsolidation) RecordLastState

func (c *EmptyNodeConsolidation) RecordLastState(currentState int64)

RecordLastState is used to record the last state that the consolidation implementation failed to work in to allow skipping future consolidation attempts until the state changes.

func (*EmptyNodeConsolidation) ShouldAttemptConsolidation

func (c *EmptyNodeConsolidation) ShouldAttemptConsolidation() bool

func (*EmptyNodeConsolidation) ShouldDeprovision

func (c *EmptyNodeConsolidation) ShouldDeprovision(ctx context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, _ []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*EmptyNodeConsolidation) String

func (c *EmptyNodeConsolidation) String() string

string is the string representation of the deprovisioner

func (*EmptyNodeConsolidation) ValidateCommand

func (c *EmptyNodeConsolidation) ValidateCommand(ctx context.Context, cmd Command, candidateNodes []CandidateNode) (bool, error)

ValidateCommand validates a command for a deprovisioner

type Expiration

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

Expiration is a subreconciler that deletes empty nodes. Expiration will respect TTLSecondsAfterEmpty

func NewExpiration

func NewExpiration(clk clock.Clock, kubeClient client.Client, cluster *state.Cluster, provisioner *provisioning.Provisioner) *Expiration

func (*Expiration) ComputeCommand

func (e *Expiration) ComputeCommand(ctx context.Context, candidates ...CandidateNode) (Command, error)

ComputeCommand generates a deprovisioning command given deprovisionable nodes

func (*Expiration) ShouldDeprovision

func (e *Expiration) ShouldDeprovision(ctx context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, nodePods []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*Expiration) SortCandidates

func (e *Expiration) SortCandidates(nodes []CandidateNode) []CandidateNode

SortCandidates orders expired nodes by when they've expired

func (*Expiration) String

func (e *Expiration) String() string

String is the string representation of the deprovisioner

type MultiNodeConsolidation

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

func NewMultiNodeConsolidation

func NewMultiNodeConsolidation(clk clock.Clock, cluster *state.Cluster, kubeClient client.Client,
	provisioner *provisioning.Provisioner, cp cloudprovider.CloudProvider, reporter *Reporter) *MultiNodeConsolidation

func (*MultiNodeConsolidation) ComputeCommand

func (m *MultiNodeConsolidation) ComputeCommand(ctx context.Context, candidates ...CandidateNode) (Command, error)

func (*MultiNodeConsolidation) RecordLastState

func (c *MultiNodeConsolidation) RecordLastState(currentState int64)

RecordLastState is used to record the last state that the consolidation implementation failed to work in to allow skipping future consolidation attempts until the state changes.

func (*MultiNodeConsolidation) ShouldAttemptConsolidation

func (c *MultiNodeConsolidation) ShouldAttemptConsolidation() bool

func (*MultiNodeConsolidation) ShouldDeprovision

func (c *MultiNodeConsolidation) ShouldDeprovision(ctx context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, _ []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*MultiNodeConsolidation) String

func (c *MultiNodeConsolidation) String() string

string is the string representation of the deprovisioner

func (*MultiNodeConsolidation) ValidateCommand

func (c *MultiNodeConsolidation) ValidateCommand(ctx context.Context, cmd Command, candidateNodes []CandidateNode) (bool, error)

ValidateCommand validates a command for a deprovisioner

type PDBLimits

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

PDBLimits is used to evaluate if evicting a list of pods is possible.

func NewPDBLimits

func NewPDBLimits(ctx context.Context, kubeClient client.Client) (*PDBLimits, error)

func (*PDBLimits) CanEvictPods

func (s *PDBLimits) CanEvictPods(pods []*v1.Pod) (client.ObjectKey, bool)

CanEvictPods returns true if every pod in the list is evictable. They may not all be evictable simultaneously, but for every PDB that controls the pods at least one pod can be evicted.

type Reporter

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

Reporter is used to periodically report node statuses regarding deprovisioning. This gives observers awareness of why deprovisioning of a particular node isn't occurring.

func NewReporter

func NewReporter(recorder events.Recorder) *Reporter

func (*Reporter) RecordUnconsolidatableReason

func (r *Reporter) RecordUnconsolidatableReason(ctx context.Context, node *v1.Node, reason string)

RecordUnconsolidatableReason is used to periodically report why a node is unconsolidatable to it can be logged

type Result

type Result byte

Result is used to indicate the action of consolidating so we can optimize by not trying to consolidate if we were unable to consolidate the cluster and it hasn't changed state with respect to pods/nodes.

const (
	ResultNothingToDo Result = iota // there are no actions that can be performed given the current cluster state
	ResultRetry                     // we attempted an action, but its validation failed so retry soon
	ResultFailed                    // the action failed entirely
	ResultSuccess                   // the action was successful
)

func (Result) String

func (r Result) String() string

type SingleNodeConsolidation

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

SingleNodeConsolidation is the consolidation controller that performs single node consolidation.

func NewSingleNodeConsolidation

func NewSingleNodeConsolidation(clk clock.Clock, cluster *state.Cluster, kubeClient client.Client, provisioner *provisioning.Provisioner,
	cp cloudprovider.CloudProvider, reporter *Reporter) *SingleNodeConsolidation

func (*SingleNodeConsolidation) ComputeCommand

func (c *SingleNodeConsolidation) ComputeCommand(ctx context.Context, candidates ...CandidateNode) (Command, error)

ComputeCommand generates a deprovisioning command given deprovisionable nodes

func (*SingleNodeConsolidation) RecordLastState

func (c *SingleNodeConsolidation) RecordLastState(currentState int64)

RecordLastState is used to record the last state that the consolidation implementation failed to work in to allow skipping future consolidation attempts until the state changes.

func (*SingleNodeConsolidation) ShouldAttemptConsolidation

func (c *SingleNodeConsolidation) ShouldAttemptConsolidation() bool

func (*SingleNodeConsolidation) ShouldDeprovision

func (c *SingleNodeConsolidation) ShouldDeprovision(ctx context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, _ []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*SingleNodeConsolidation) String

func (c *SingleNodeConsolidation) String() string

string is the string representation of the deprovisioner

func (*SingleNodeConsolidation) ValidateCommand

func (c *SingleNodeConsolidation) ValidateCommand(ctx context.Context, cmd Command, candidateNodes []CandidateNode) (bool, error)

ValidateCommand validates a command for a deprovisioner

type Validation

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

Validation is used to perform validation on a consolidation command. It makes an assumption that when re-used, all of the commands passed to IsValid were constructed based off of the same consolidation state. This allows it to skip the validation TTL for all but the first command.

func NewValidation

func NewValidation(validationPeriod time.Duration, clk clock.Clock, cluster *state.Cluster, kubeClient client.Client, provisioner *provisioning.Provisioner, cp cloudprovider.CloudProvider) *Validation

func (*Validation) IsValid

func (v *Validation) IsValid(ctx context.Context, cmd Command) (bool, error)

func (*Validation) ShouldDeprovision

func (v *Validation) ShouldDeprovision(_ context.Context, n *state.Node, provisioner *v1alpha5.Provisioner, _ []*v1.Pod) bool

ShouldDeprovision is a predicate used to filter deprovisionable nodes

func (*Validation) ValidateCommand

func (v *Validation) ValidateCommand(ctx context.Context, cmd Command, candidateNodes []CandidateNode) (bool, error)

ValidateCommand validates a command for a deprovisioner

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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