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 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 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) (NodeStateLabel, 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 Apply ¶
func Apply(state NodeState, node *v1.Node, data *Data, params plugin.Parameters) (NodeStateLabel, 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.
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 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
}