action

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2021 License: Apache-2.0, BSD-3-Clause, MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Adjust   ActionType = "adjust"
	Schedule ActionType = "schedule"
	Evict    ActionType = "evict"
	Log      ActionType = "log"

	// FormulaStep means removed step by step, and it's negative value if the resource is conflicting
	FormulaStep ActionFormula = "step"
	// FormulaTotal means removed by total, and it's negative value if the resource is conflicting
	FormulaTotal ActionFormula = "total"
	// FormulaPercent means removed by percent, and it's negative value if the resource is conflicting
	FormulaPercent ActionFormula = "percent"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	ActionType() ActionType
	DoAction(conflicting bool, data interface{}) (*ActionResult, error)
}

Action is the interface of actions when rules match

func NewAdjustResourceAction

func NewAdjustResourceAction(resourceName v1.ResourceName, args []byte) Action

NewAdjustResourceAction return AdjustResourceAction

func NewEvictAction

func NewEvictAction() Action

NewEvictAction get action instance to evict app

func NewLogAction

func NewLogAction() Action

NewLogAction get Action instance to send alarms

func NewScheduleAction

func NewScheduleAction(name string) Action

NewScheduleAction get Action instance to unschedule offline job

type ActionFormula

type ActionFormula string

type ActionResource

type ActionResource struct {
	Name             v1.ResourceName
	Conflicting      bool
	ConflictQuantity map[ActionFormula]api.Quantity
}

ActionResource records resource quantity need to remove or add.

func (ActionResource) DeepCopy

func (a ActionResource) DeepCopy() ActionResource

DeepCopy copy ActionResource

func (*ActionResource) Equal

func (a *ActionResource) Equal(b *ActionResource) bool

Equal check if the two actionResource is equal

func (ActionResource) IsNegative

func (a ActionResource) IsNegative() bool

IsNegative returns if conflicting or conflict resource is negative

func (ActionResource) MergeByLittle

func (a ActionResource) MergeByLittle(b ActionResource) ActionResource

MergeByLittle merge two ActionResource into one, and choose the little conflicting value

type ActionResult

type ActionResult struct {
	UnscheduleMap   map[string]bool
	EvictPods       []k8stypes.NamespacedName
	AdjustResources map[v1.ResourceName]ActionResource
	SyncEvent       bool
	Messages        []string
}

ActionResult is the result of actions

func (*ActionResult) Merge

func (ar *ActionResult) Merge(other *ActionResult)

Merge merge the other action result

func (*ActionResult) String

func (ar *ActionResult) String() string

String implements Stringer interface

type ActionType

type ActionType string

type AdjustResourceAction

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

AdjustResourceAction get Action instance to adjust offline resources

func (*AdjustResourceAction) ActionType

func (a *AdjustResourceAction) ActionType() ActionType

ActionType return current action type

func (*AdjustResourceAction) DoAction

func (a *AdjustResourceAction) DoAction(conflicting bool, data interface{}) (*ActionResult, error)

DoAction handle check result

func (*AdjustResourceAction) InitSelfHandler

func (a *AdjustResourceAction) InitSelfHandler(resource v1.ResourceName, handler AdjustSelfDefineFunc)

InitSelfHandler init resource adjust handler

func (*AdjustResourceAction) ResourceName

func (a *AdjustResourceAction) ResourceName() v1.ResourceName

ResourceName returns checked resource name

type AdjustSelfDefineFunc

type AdjustSelfDefineFunc func(conflicting bool) *ActionResource

Jump to

Keyboard shortcuts

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