healthcheck

package
v1.58.2 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 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"
)

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 client.ObjectList representation of the extension to register getExtensionObjFunc returns a extensionsv1alpha1.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(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.

func SeedClientInto added in v1.12.0

func SeedClientInto(client client.Client, i interface{}) bool

SeedClientInto will set the seed client on i if i implements SeedClient.

func ShootClientInto added in v1.12.0

func ShootClientInto(client client.Client, i interface{}) bool

ShootClientInto will set the shoot client on i if i implements ShootClient.

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, log logr.Logger, request types.NamespacedName) (*[]Result, error)

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

func (*Actuator) InjectClient

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

InjectClient injects the given client.Client into this Actuator.

func (*Actuator) InjectConfig

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

InjectConfig injects the given rest.Config into this Actuator.

func (*Actuator) InjectScheme

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

InjectScheme injects the given runtime.Scheme into this Actuator.

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 client.ObjectList 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

GetExtensionGroupVersionKind returns the schema.GroupVersionKind of the registered extension of this AddArgs.

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
	ErrorCodeCheckFunc ErrorCodeCheckFunc
}

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 extensionsconfig.HealthCheckConfig
}

DefaultAddArgs are the default Args for the health check controller.

type ErrorCodeCheckFunc added in v1.57.0

type ErrorCodeCheckFunc = func(error) []gardencorev1beta1.ErrorCode

ErrorCodeCheckFunc checks if the given error is user specific and return respective Gardener ErrorCodes.

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() client.ObjectList

GetExtensionObjectListFunc returns the extension object list that should be registered with the health check controller. For example: func() client.ObjectList { 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)
	// 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 results.
	// Returns
	//  - Result for each healthConditionTypes registered with the individual health checks.
	//  - an error if it could not execute the health checks.
	//    This results in a condition with with type "Unknown" with reason "ConditionCheckError".
	ExecuteHealthCheckFunctions(context.Context, logr.Logger, types.NamespacedName) (*[]Result, error)
}

HealthCheckActuator acts upon registered resources.

func NewActuator

func NewActuator(provider, extensionKind string, getExtensionObjFunc GetExtensionObjectFunc, healthChecks []ConditionTypeToHealthCheck, shootRESTOptions extensionsconfig.RESTOptions) HealthCheckActuator

NewActuator creates a new Actuator.

type PreCheckFunc

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 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 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 to why the health checks are unsuccessful
	Detail *string
	// SuccessfulChecks is the amount of successful health checks
	SuccessfulChecks int
	// ProgressingChecks is the amount of progressing health checks
	ProgressingChecks int
	// UnsuccessfulChecks is the amount of unsuccessful health checks
	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 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. A Result refers to a single healthConditionType (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 SeedClient added in v1.12.0

type SeedClient interface {
	// InjectSeedClient injects the seed client
	InjectSeedClient(client.Client)
}

SeedClient is an interface to be used to receive a seed client.

type ShootClient added in v1.12.0

type ShootClient interface {
	// InjectShootClient injects the shoot client
	InjectShootClient(client.Client)
}

ShootClient is an interface to be used to receive a shoot client.

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
	// 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