maintenance

package
v0.0.0-...-aa25bfb Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: AGPL-3.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicHTTPMaintenanceTrigger

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

BasicHTTPMaintenanceTrigger gets the critical status from an HTTP response containing only a truthy or falsy string. This is used typically to trigger emergency maintenances from a file hosted in a s3 bucket or raw file served over HTTP. BasicHTTPMaintenanceTrigger uses basicHTTPMaintenanceClient and wraps it in a cache in order to mitigate the impact of too frequent reconciliations. The structure implements the maintenance.Trigger interface.

func (BasicHTTPMaintenanceTrigger) CanStart

CanStart implements maintenance.Trigger

func (BasicHTTPMaintenanceTrigger) Default

func (g BasicHTTPMaintenanceTrigger) Default() bool

Default returns what to do if the trigger can't be evaluated. BasicHTTPMaintenanceTrigger should fail open, so the function returns true.

func (BasicHTTPMaintenanceTrigger) Name

Name implements maintenance.Triggernd returns the trigger name for logging and debugging pursposes.

type Trigger

type Trigger interface {
	Name() string
	CanStart(ctx context.Context, object client.Object) (bool, error)
	Default() bool
}

Trigger is evaluated to decide whether a maintenance can happen or not. Maintenances can happen because of multiple reasons like: - attempt to recover from a broken state - we are in a maintenance window - emergency security patch Each Trigger has a Name() for logging purposes and a Default() method returning whether the trigger should allow the maintenance or not in case\ of error.

func NewBasicHTTPMaintenanceTrigger

func NewBasicHTTPMaintenanceTrigger(name string, baseURL *url.URL) Trigger

NewBasicHTTPMaintenanceTrigger builds and return a Trigger checking a public HTTP endpoint.

func NewMaintenanceTriggerMock

func NewMaintenanceTriggerMock(name string, canStart bool) Trigger

NewMaintenanceTriggerMock creates a TriggerMock

func NewUnhealthyWorkloadTrigger

func NewUnhealthyWorkloadTrigger(name string, client kclient.Client) Trigger

NewUnhealthyWorkloadTrigger triggers a maintenance if the watched workload is unhealthy.

func NewWindowTrigger

func NewWindowTrigger(name string, client kclient.Client) Trigger

NewWindowTrigger returns a new Trigger validating if the agent is within its maintenance window.

type TriggerMock

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

TriggerMock is a fake Trigger that return a static answer. This is used for testing purposes and is inherently disruptive.

func (TriggerMock) CanStart

func (m TriggerMock) CanStart(_ context.Context, _ client.Object) (bool, error)

CanStart returns the statically defined maintenance approval result.

func (TriggerMock) Default

func (m TriggerMock) Default() bool

Default returns the default behavior if the trigger fails. This cannot happen for a TriggerMock and is here solely to implement the Trigger interface.

func (TriggerMock) Name

func (m TriggerMock) Name() string

Name returns the TriggerMock name.

type Triggers

type Triggers []Trigger

Triggers is a list of Trigger. Triggers are OR-ed: any trigger firing in the list will cause the maintenance to be triggered.

func (Triggers) CanStart

func (t Triggers) CanStart(ctx context.Context, object client.Object) bool

CanStart checks if the maintenance can be started. It will return true if at least a Trigger approves the maintenance.

Jump to

Keyboard shortcuts

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