controllers

package
v0.0.0-...-9d1fdd8 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 43 Imported by: 0

Documentation

Overview

Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2024 Datadog, Inc.

Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2024 Datadog, Inc.

Index

Constants

View Source
const (
	ScheduledAtAnnotation          = chaosv1beta1.GroupName + "/scheduled-at"
	DisruptionCronNameLabel        = chaosv1beta1.GroupName + "/disruption-cron-name"
	DisruptionRolloutNameLabel     = chaosv1beta1.GroupName + "/disruption-rollout-name"
	TargetResourceMissingThreshold = time.Hour * 24
)
View Source
const TargetsCountLogLimit = 50

Variables

View Source
var DisruptionCronTags = []string{}
View Source
var DisruptionRolloutTags = []string{}

Functions

func CheckTargetResourceExists

func CheckTargetResourceExists(ctx context.Context, cl client.Client, targetResource *chaosv1beta1.TargetResourceSpec, namespace string) (bool, error)

CheckTargetResourceExists determines if the target resource exists. Returns a boolean indicating presence and an error if one occurs.

func CreateDisruptionFromTemplate

func CreateDisruptionFromTemplate(ctx context.Context, cl client.Client, scheme *runtime.Scheme, owner metav1.Object, targetResource *chaosv1beta1.TargetResourceSpec, disruptionSpec *chaosv1beta1.DisruptionSpec, scheduledTime time.Time) (*chaosv1beta1.Disruption, error)

CreateDisruptionFromTemplate constructs a Disruption object based on the provided owner, disruptionSpec, and targetResource. The function sets annotations, overwrites selectors, and associates the Disruption with its owner. It returns the constructed Disruption or an error if any step fails.

func GetChildDisruptions

func GetChildDisruptions(ctx context.Context, cl client.Client, log *zap.SugaredLogger, namespace, labelKey, labelVal string) (*chaosv1beta1.DisruptionList, error)

GetChildDisruptions retrieves disruptions associated with a resource by its label. Most of the time, this will return an empty list as disruptions are typically short-lived objects.

func GetMostRecentScheduleTime

func GetMostRecentScheduleTime(log *zap.SugaredLogger, disruptions *chaosv1beta1.DisruptionList) time.Time

GetMostRecentScheduleTime returns the most recent scheduled time from a list of disruptions.

func GetSelectors

func GetSelectors(ctx context.Context, cl client.Client, targetResource *chaosv1beta1.TargetResourceSpec, namespace string) (labels.Set, error)

GetSelectors retrieves the labels of the specified target resource (Deployment or StatefulSet). Returns a set of labels to be used as Disruption selectors and an error if retrieval fails.

func GetTargetResource

func GetTargetResource(ctx context.Context, cl client.Client, targetResource *chaosv1beta1.TargetResourceSpec, namespace string) (client.Object, error)

GetTargetResource retrieves the specified target resource (Deployment or StatefulSet). It returns the target resource object and any error encountered during retrieval.

Types

type CtxTuple

type CtxTuple struct {
	Ctx                      context.Context
	CancelFunc               context.CancelFunc
	DisruptionNamespacedName types.NamespacedName
}

type DisruptionCronReconciler

type DisruptionCronReconciler struct {
	Client  client.Client
	Scheme  *runtime.Scheme
	BaseLog *zap.SugaredLogger

	MetricsSink metrics.Sink
	// contains filtered or unexported fields
}

func (*DisruptionCronReconciler) Reconcile

func (r *DisruptionCronReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, err error)

func (*DisruptionCronReconciler) SetupWithManager

func (r *DisruptionCronReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager setups the current reconciler with the given manager

type DisruptionReconciler

type DisruptionReconciler struct {
	Client         client.Client
	BaseLog        *zap.SugaredLogger
	Scheme         *runtime.Scheme
	Recorder       record.EventRecorder
	MetricsSink    metrics.Sink
	TracerSink     tracer.Sink
	TargetSelector targetselector.TargetSelector

	SafetyNets                 []safemode.Safemode
	ExpiredDisruptionGCDelay   *time.Duration
	CacheContextStore          map[string]CtxTuple
	DisruptionsWatchersManager watchers.DisruptionsWatchersManager
	ChaosPodService            services.ChaosPodService
	CloudService               cloudservice.CloudServicesProvidersManager
	DisruptionsDeletionTimeout time.Duration
	// contains filtered or unexported fields
}

DisruptionReconciler reconciles a Disruption object

func (*DisruptionReconciler) Reconcile

func (r *DisruptionReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, err error)

func (*DisruptionReconciler) ReportMetrics

func (r *DisruptionReconciler) ReportMetrics(ctx context.Context)

ReportMetrics reports some controller metrics every minute: - stuck on removal disruptions count - ongoing disruptions count

func (*DisruptionReconciler) SetupWithManager

func (r *DisruptionReconciler) SetupWithManager(mgr ctrl.Manager, kubeInformerFactory kubeinformers.SharedInformerFactory) (controller.Controller, error)

SetupWithManager setups the current reconciler with the given manager

type DisruptionRolloutReconciler

type DisruptionRolloutReconciler struct {
	Client  client.Client
	Scheme  *runtime.Scheme
	BaseLog *zap.SugaredLogger

	MetricsSink metrics.Sink
	// contains filtered or unexported fields
}

func (*DisruptionRolloutReconciler) Reconcile

func (r *DisruptionRolloutReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, err error)

func (*DisruptionRolloutReconciler) SetupWithManager

func (r *DisruptionRolloutReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager setups the current reconciler with the given manager

Jump to

Keyboard shortcuts

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