Documentation ¶
Index ¶
- func ContainsProfile(allProfiles, profile string) bool
- type ApplyResult
- type Data
- type DataV2
- type NodeInfo
- type NodeState
- type NodeStateLabel
- type PluginChains
- type Profile
- type ProfileData
- type ProfileResult
- type ProfileSelector
- type ProfileState
- type Transition
- type TransitionResult
- type TransitionsResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsProfile ¶ added in v0.19.3
Returns whether profile is contained in the profile label value.
Types ¶
type ApplyResult ¶ added in v1.0.0
type ApplyResult struct { Next NodeStateLabel `json:"next"` Transitions []TransitionResult `json:"transitions"` Error string `json:"error"` }
func Apply ¶
func Apply(state NodeState, node *v1.Node, data *DataV2, params plugin.Parameters) (ApplyResult, error)
Calls all Notification Plugins, checks for a transition and invokes all trigger plugins if a transitions happens. Returns the next node state. In case of an error state.Label() is retuned alongside with the error.
type Data ¶
type Data struct { LastTransition time.Time // Maps a notification instance name to the last time it was triggered. LastNotificationTimes map[string]time.Time // Current states of assigned profiles ProfileStates map[string]NodeStateLabel // States of profiles of the previous reconciliation PreviousStates map[string]NodeStateLabel }
Data represents global state which is saved with a node annotation.
type DataV2 ¶ added in v1.2.0
type DataV2 struct { Profiles map[string]*ProfileData // Maps a notification instance name to the last time it was triggered. Notifications map[string]time.Time }
func ParseDataV2 ¶ added in v1.2.0
func ParseMigrateDataV2 ¶ added in v1.2.0
func (*DataV2) GetProfilesWithState ¶ added in v1.2.0
func (d *DataV2) GetProfilesWithState(profilesStr string, availableProfiles map[string]Profile) []ProfileState
Returns a Profile instance with its corresponding state for each profile named in profileStr. If profileStr is an empty string, falls back to the default profile. Call MaintainProfileStates before.
type NodeState ¶
type NodeState interface { // Label is the Label associated with the state Label() NodeStateLabel // Enter is executed when a node enters a new state. // Its not executed when a profile gets freshly attached. Enter(params plugin.Parameters, data *DataV2) error // Notify executes the notification chain if required Notify(params plugin.Parameters, data *DataV2) error // Trigger executes the trigger chain Trigger(params plugin.Parameters, next NodeStateLabel, data *DataV2) error // Trigger executes the check chain and determines, which state should be the next one. // If an error is returned the NodeStateLabel must match the current state. Transition(params plugin.Parameters, data *DataV2) (TransitionsResult, error) }
NodeState represents the state a node can be in.
func FromLabel ¶
func FromLabel(label NodeStateLabel, chains PluginChains) (NodeState, error)
FromLabel creates a new NodeState instance identified by the label with given chains and notification interval.
type NodeStateLabel ¶
type NodeStateLabel string
NodeStateLabel reprensents labels which nodes a marked with.
const InMaintenance NodeStateLabel = "in-maintenance"
InMaintenance is a label that marks a node which is currently in maintenance.
const Operational NodeStateLabel = "operational"
Operational is a label that marks a node which is operational.
const Required NodeStateLabel = "maintenance-required"
Required is a label that marks a node which needs to be maintenaned.
func ValidateLabel ¶
func ValidateLabel(s string) (NodeStateLabel, error)
Returns whether s as NodeStateLabel if it is valid.
type PluginChains ¶
type PluginChains struct { Enter plugin.TriggerChain Notification plugin.NotificationChain Transitions []Transition }
PluginChains is a struct containing a plugin chain of each plugin type.
type Profile ¶
type Profile struct { Name string Chains map[NodeStateLabel]PluginChains }
Profile contains its name and attached plugin chains.
type ProfileData ¶ added in v1.2.0
type ProfileData struct { Transition time.Time Current NodeStateLabel Previous NodeStateLabel }
type ProfileResult ¶ added in v1.0.0
type ProfileResult struct { Applied ApplyResult `json:"applied"` Name string `json:"name"` State NodeStateLabel `json:"state"` }
type ProfileSelector ¶
type ProfileSelector struct { NodeState NodeStateLabel NodeProfiles string AvailableProfiles map[string]Profile Data Data }
type ProfileState ¶ added in v0.16.0
type ProfileState struct { Profile Profile State NodeStateLabel }
type Transition ¶
type Transition struct { Check plugin.CheckChain Trigger plugin.TriggerChain Next NodeStateLabel }
func (*Transition) Execute ¶ added in v1.0.0
func (t *Transition) Execute(params plugin.Parameters) (TransitionResult, error)
type TransitionResult ¶ added in v1.0.0
type TransitionResult struct { Passed bool `json:"passed"` Target NodeStateLabel `json:"target"` Chain plugin.CheckChainResult `json:"chain"` Error string `json:"error"` }
type TransitionsResult ¶ added in v1.0.0
type TransitionsResult struct { Next NodeStateLabel `json:"next"` Infos []TransitionResult `json:"infos"` }