Documentation ¶
Index ¶
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 *Data, 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.
func (*Data) GetProfilesWithState ¶ added in v0.16.0
func (d *Data) 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.
func (*Data) MaintainPreviousStates ¶ added in v0.16.3
Removes previous state data for removed profile and initializes it for added profiles.
type NodeInfo ¶ added in v1.0.0
type NodeInfo struct { Node string `json:"node"` Profiles []ProfileResult `json:"profiles"` Updated time.Time `json:"updated"` }
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 *Data) error // Notify executes the notification chain if required Notify(params plugin.Parameters, data *Data) error // Trigger executes the trigger chain Trigger(params plugin.Parameters, next NodeStateLabel, data *Data) 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 *Data) (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 { 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 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"` }