healthcheck

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 36 Imported by: 59

Documentation

Index

Constants

View Source
const (
	// ReasonUnsuccessful is the reason phrase for the health check condition if one or more of its tests failed.
	ReasonUnsuccessful = "HealthCheckUnsuccessful"
	// ReasonProgressing is the reason phrase for the health check condition if one or more of its tests are progressing.
	ReasonProgressing = "HealthCheckProgressing"
	// ReasonSuccessful is the reason phrase for the health check condition if all tests are successful.
	ReasonSuccessful = "HealthCheckSuccessful"
)
View Source
const (
	// ControllerName is the name of the controller.
	ControllerName = "healthcheck_controller"
)

Variables

This section is empty.

Functions

func DefaultPredicates

func DefaultPredicates() []predicate.Predicate

DefaultPredicates returns the default predicates.

func DefaultRegistration

func DefaultRegistration(extensionType string, kind schema.GroupVersionKind, getExtensionObjListFunc GetExtensionObjectListFunc, getExtensionObjFunc GetExtensionObjectFunc, mgr manager.Manager, opts DefaultAddArgs, customPredicates []predicate.Predicate, healthChecks []ConditionTypeToHealthCheck) error

DefaultRegistration configures the default health check NewActuator to execute the provided health checks and adds it to the provided controller-runtime manager. the NewActuator reconciles a single extension with a specific type and writes conditions for each distinct healthConditionTypes. extensionType (e.g aws) defines the spec.type of the extension to watch kind defines the GroupVersionKind of the extension GetExtensionObjListFunc returns a list of the runtime.Object representation of the extension to register getExtensionObjFunc returns a runtime.Object representation of the extension to register mgr is the controller runtime manager opts contain config for the healthcheck controller custom predicates allow for fine-grained control which resources to watch healthChecks defines the checks to execute mapped to the healthConditionTypes its contributing to (e.g checkDeployment in Seed -> ControlPlaneHealthy). register returns a runtime representation of the extension resource to register it with the controller-runtime

func NewReconciler

func NewReconciler(mgr manager.Manager, actuator HealthCheckActuator, registeredExtension RegisteredExtension, syncPeriod metav1.Duration) reconcile.Reconciler

NewReconciler creates a new performHealthCheck.Reconciler that reconciles the registered extension resources (Gardener's `extensions.gardener.cloud` API group).

func Register

func Register(mgr manager.Manager, args AddArgs, actuator HealthCheckActuator) error

Register the extension resource. Must be of type extensionsv1alpha1.Object Add creates a new Reconciler and adds it to the Manager. and Start it when the Manager is Started.

Types

type Actuator

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

Actuator contains all the health checks and the means to execute them

func (*Actuator) ExecuteHealthCheckFunctions

func (a *Actuator) ExecuteHealthCheckFunctions(ctx context.Context, request types.NamespacedName) (*[]Result, error)

ExecuteHealthCheckFunctions executes all the health check functions, injects clients and logger & aggregates the results. returns an Result for each HealthConditionTyp (e.g ControlPlaneHealthy)

func (*Actuator) InjectClient

func (a *Actuator) InjectClient(client client.Client) error

func (*Actuator) InjectConfig

func (a *Actuator) InjectConfig(config *rest.Config) error

func (*Actuator) InjectScheme

func (a *Actuator) InjectScheme(scheme *runtime.Scheme) error

type AddArgs

type AddArgs struct {
	// ControllerOptions are the controller options used for creating a controller.
	// The options.Reconciler is always overridden with a reconciler created from the
	// given actuator.
	ControllerOptions controller.Options
	// Predicates are the predicates to use.
	// If unset, GenerationChanged will be used.
	Predicates []predicate.Predicate
	// Type is the type of the resource considered for reconciliation.
	Type string
	// SyncPeriod is the duration how often the registered extension is being reconciled
	SyncPeriod metav1.Duration

	// GetExtensionObjListFunc returns a list of the runtime.Object representation of the extension to register
	GetExtensionObjListFunc GetExtensionObjectListFunc
	// contains filtered or unexported fields
}

AddArgs are arguments for adding an health check controller to a controller-runtime manager.

func (*AddArgs) GetExtensionGroupVersionKind

func (a *AddArgs) GetExtensionGroupVersionKind() schema.GroupVersionKind

func (*AddArgs) RegisterExtension

func (a *AddArgs) RegisterExtension(getExtensionObjFunc GetExtensionObjectFunc, conditionTypes []string, kind schema.GroupVersionKind) error

RegisterExtension registered a resource and its corresponding healthCheckTypes. throws and error if the extensionResources is not a extensionsv1alpha1.Object The controller writes the healthCheckTypes as a condition.type into the extension resource. To contribute to the Shoot's health, the Gardener checks each extension for a Health Condition Type of SystemComponentsHealthy, EveryNodeReady, ControlPlaneHealthy. However extensions are free to choose any healthCheckType

type ConditionTypeToHealthCheck

type ConditionTypeToHealthCheck struct {
	ConditionType string
	PreCheckFunc  PreCheckFunc
	HealthCheck   HealthCheck
}

ConditionTypeToHealthCheck registers a HealthCheck for the given ConditionType. If the PreCheckFunc is not nil it will be executed with the given object before the health check if performed. Otherwise, the health check will always be performed.

type DefaultAddArgs

type DefaultAddArgs struct {
	// Controller are the controller.Options.
	Controller controller.Options
	// HealthCheckConfig contains additional config for the health check controller
	HealthCheckConfig healthcheckconfig.HealthCheckConfig
}

DefaultAddArgs are the default Args for the health check controller.

type GetExtensionObjectFunc

type GetExtensionObjectFunc = func() extensionsv1alpha1.Object

GetExtensionObjectFunc returns the extension object that should be registered with the health check controller. For example: func() extensionsv1alpha1.Object {return &extensionsv1alpha1.Worker{}}

type GetExtensionObjectListFunc added in v1.4.0

type GetExtensionObjectListFunc = func() runtime.Object

GetExtensionObjectFunc returns the extension object that should be registered with the health check controller. Has to be a List. For example: func() runtime.Object {return &extensionsv1alpha1.WorkerList{}}

type HealthCheck

type HealthCheck interface {
	// Check is the function that executes the actual health check
	Check(context.Context, types.NamespacedName) (*SingleCheckResult, error)
	// InjectSeedClient injects the seed client
	InjectSeedClient(client.Client)
	// InjectShootClient injects the shoot client
	InjectShootClient(client.Client)
	// SetLoggerSuffix injects the logger
	SetLoggerSuffix(string, string)
	// DeepCopy clones the healthCheck
	DeepCopy() HealthCheck
}

HealthCheck represents a single health check Each health check gets the shoot and seed clients injected returns isHealthy, conditionReason, conditionDetail and error returning an error means the health check could not be conducted and will result in a condition with with type "Unknown" and reason "ConditionCheckError"

type HealthCheckActuator

type HealthCheckActuator interface {
	// ExecuteHealthCheckFunctions is regularly called by the health check controller
	// Executes all registered Health Checks and aggregates the result
	// Returns Result for each healthConditionTypes registered with the individual health checks.
	// returns an error if it could not execute the health checks
	// returning an error results in a condition with with type "Unknown" with reason "ConditionCheckError"
	ExecuteHealthCheckFunctions(context.Context, types.NamespacedName) (*[]Result, error)
}

HealthCheckActuator acts upon registered resources.

func NewActuator

func NewActuator(provider, extensionKind string, getExtensionObjFunc GetExtensionObjectFunc, healthChecks []ConditionTypeToHealthCheck) HealthCheckActuator

NewActuator creates a new Actuator.

type PreCheckFunc

type PreCheckFunc = func(runtime.Object, *extensionscontroller.Cluster) bool

PreCheckFunc checks whether the health check shall be performed based on the given object and cluster.

type RegisteredExtension

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

RegisteredExtension is a registered extensions that the HealthCheck Controller watches. The field extension contains any extension object The field healthConditionTypes contains all distinct healthCondition types (extracted from the healthCheck). They are being used as the .type field of the Condition that the HealthCheck controller writes to the extension Resource. The field groupVersionKind stores the GroupVersionKind of the extension resource

type Result

type Result struct {
	// HealthConditionType is being used as the .type field of the Condition that the HealthCheck controller writes to the extension Resource.
	// To contribute to the Shoot's health, the Gardener checks each extension for a Health Condition Type of SystemComponentsHealthy, EveryNodeReady, ControlPlaneHealthy.
	HealthConditionType string
	// Status contains the status for the health checks that have been performed for an extension resource
	Status gardencorev1beta1.ConditionStatus
	// Detail contains details for health checks being unsuccessful
	Detail *string
	// SuccessfulChecks is the amount of successful health checks
	SuccessfulChecks int
	// ProgressingChecks is the amount of health checks that were progressing
	ProgressingChecks int
	// UnsuccessfulChecks is the amount of health checks that were not successful
	UnsuccessfulChecks int
	// FailedChecks is the amount of health checks that could not be performed (e.g client could not reach Api Server)
	// Results in a condition with with type "Unknown" with reason "ConditionCheckError" for this healthConditionType
	FailedChecks int
	// Codes is an optional list of error codes that were produced by the the health checks.
	Codes []gardencorev1beta1.ErrorCode
	// ProgressingThreshold is the threshold duration after which a health check that reported the `Progressing` status
	// shall be transitioned to `False`
	ProgressingThreshold *time.Duration
}

Result represents an aggregated health status for the health checks performed on the dependent API Objects of an extension resource. An Result refers to a single healthConditionTypes (e.g SystemComponentsHealthy) of an extension Resource.

func (*Result) GetDetails

func (h *Result) GetDetails() string

GetDetails returns the details of the health check result

type SingleCheckResult

type SingleCheckResult struct {
	// Status contains the status for the health check that has been performed for an extension resource
	Status gardencorev1beta1.ConditionStatus
	// Detail contains details for the health check being unsuccessful
	Detail string
	// Reason contains the reason for the health check being unsuccessful
	Reason string
	// Codes optionally contains a list of error codes related to the health check
	Codes []gardencorev1beta1.ErrorCode
	// ProgressingThreshold is the threshold duration after which a health check that reported the `Progressing` status
	// shall be transitioned to `False`
	ProgressingThreshold *time.Duration
}

SingleCheckResult is the result for a health check

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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