watchers

package
v0.0.0-...-51bb0a0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 31 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.

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.

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.

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.

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 ChaosPodHandlerName = "ChaosPodHandler"
View Source
const DisruptionTargetHandlerName = "DisruptionTargetHandler"

Variables

This section is empty.

Functions

func ContainersChanged

func ContainersChanged(oldPodSpec, newPodSpec *corev1.PodSpec, log *zap.SugaredLogger) (bool, map[string]string, map[string]string, error)

func Hash

func Hash(container *corev1.Container) (string, error)

func HashContainerList

func HashContainerList(containers *[]corev1.Container) (map[string]string, error)

func HashPodSpec

func HashPodSpec(podSpec *corev1.PodSpec) (map[string]string, map[string]string, error)

func HashesChanged

func HashesChanged(oldHashes, newHashes map[string]string, log *zap.SugaredLogger) bool

Types

type CacheContextFunc

type CacheContextFunc func() (ctx context.Context, cancel context.CancelFunc)

CacheContextFunc is a function that returns a context and a cancel function.

type CacheContextFuncMock

type CacheContextFuncMock struct {
	mock.Mock
}

CacheContextFuncMock is an autogenerated mock type for the CacheContextFunc type

func NewCacheContextFuncMock

func NewCacheContextFuncMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *CacheContextFuncMock

NewCacheContextFuncMock creates a new instance of CacheContextFuncMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*CacheContextFuncMock) EXPECT

func (*CacheContextFuncMock) Execute

Execute provides a mock function with given fields:

type CacheContextFuncMock_Execute_Call

type CacheContextFuncMock_Execute_Call struct {
	*mock.Call
}

CacheContextFuncMock_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute'

func (*CacheContextFuncMock_Execute_Call) Return

func (*CacheContextFuncMock_Execute_Call) Run

func (*CacheContextFuncMock_Execute_Call) RunAndReturn

type CacheContextFuncMock_Expecter

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

func (*CacheContextFuncMock_Expecter) Execute

Execute is a helper method to define mock.On call

type ChaosPodHandler

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

ChaosPodHandler handles the lifecycle of chaos pods to send notifications if needed

func NewChaosPodHandler

func NewChaosPodHandler(disruption *chaosv1beta1.Disruption, recorder record.EventRecorder, logger *zap.SugaredLogger, metricsAdapter WatcherMetricsAdapter) ChaosPodHandler

NewChaosPodHandler creates a new instance of ChaosPodHandler

func (ChaosPodHandler) OnAdd

func (w ChaosPodHandler) OnAdd(_ interface{}, _ bool)

OnAdd is a handler function for the add of the chaos pod

func (ChaosPodHandler) OnDelete

func (w ChaosPodHandler) OnDelete(_ interface{})

OnDelete is a handler function for the delete of the chaos pod

func (ChaosPodHandler) OnUpdate

func (w ChaosPodHandler) OnUpdate(oldObj, newObj interface{})

OnUpdate is a handler function for the update of the chaos pod

type CtxTuple

type CtxTuple struct {
	// CancelFunc is a function that can be called to cancel the associated context.
	CancelFunc context.CancelFunc

	// Ctx is a context.Context object that is used to manage the lifetime of an operation.
	Ctx context.Context

	// DisruptionNamespacedName is the namespaced name of a Disruption resource that is associated with this CtxTuple.
	DisruptionNamespacedName types.NamespacedName
}

CtxTuple is a struct that holds a context and its cancel function, as well as a NamespacedName that identifies a Disruption resource.

type DeploymentHandler

type DeploymentHandler struct {
	Client client.Client
	// contains filtered or unexported fields
}

func NewDeploymentHandler

func NewDeploymentHandler(client client.Client, logger *zap.SugaredLogger) DeploymentHandler

func (DeploymentHandler) FetchAssociatedDisruptionRollouts

func (h DeploymentHandler) FetchAssociatedDisruptionRollouts(deployment *appsv1.Deployment) (*chaosv1beta1.DisruptionRolloutList, error)

func (DeploymentHandler) HasAssociatedDisruptionRollout

func (h DeploymentHandler) HasAssociatedDisruptionRollout(deployment *appsv1.Deployment) (bool, error)

func (DeploymentHandler) OnAdd

func (h DeploymentHandler) OnAdd(obj interface{})

OnAdd is a handler function for the add of a deployment

func (DeploymentHandler) OnDelete

func (h DeploymentHandler) OnDelete(_ interface{})

OnDelete is a handler function for the delete of a deployment

func (DeploymentHandler) OnUpdate

func (h DeploymentHandler) OnUpdate(oldObj, newObj interface{})

OnUpdate is a handler function for the update of a deployment

func (DeploymentHandler) UpdateDisruptionRolloutStatus

func (h DeploymentHandler) UpdateDisruptionRolloutStatus(deployment *appsv1.Deployment, initContainersHash, containersHash map[string]string) error

type DisruptionTargetHandler

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

DisruptionTargetHandler struct used to manage what to do when changes occur on the watched objects in the cache

func (DisruptionTargetHandler) OnAdd

func (d DisruptionTargetHandler) OnAdd(obj interface{}, _ bool)

OnAdd new target

func (DisruptionTargetHandler) OnChangeHandleMetricsSink

func (d DisruptionTargetHandler) OnChangeHandleMetricsSink(pod *corev1.Pod, node *corev1.Node, okPod, okNode bool, event WatcherEventType)

OnChangeHandleMetricsSink Trigger Metric Sink on changes in the targets

func (DisruptionTargetHandler) OnChangeHandleNotifierSink

func (d DisruptionTargetHandler) OnChangeHandleNotifierSink(oldPod, newPod *corev1.Pod, oldNode, newNode *corev1.Node, okOldPod, okNewPod, okOldNode, okNewNode bool)

OnChangeHandleNotifierSink Trigger Notifier Sink on changes in the targets

func (DisruptionTargetHandler) OnDelete

func (d DisruptionTargetHandler) OnDelete(obj interface{})

OnDelete target

func (DisruptionTargetHandler) OnUpdate

func (d DisruptionTargetHandler) OnUpdate(oldObj, newObj interface{})

OnUpdate target

type DisruptionsWatchersManager

type DisruptionsWatchersManager interface {
	// CreateAllWatchers adds new Watchers instances for a disruption
	CreateAllWatchers(disruption *v1beta1.Disruption, watcherManagerMock Manager, cacheMock k8scontrollercache.Cache) error

	// RemoveAllWatchers removes all existing Watchers of a disruption
	RemoveAllWatchers(disruption *v1beta1.Disruption)

	// RemoveAllOrphanWatchers removes all watchers linked to an expired disruption
	RemoveAllOrphanWatchers() error

	// RemoveAllExpiredWatchers removes all expired Watchers
	RemoveAllExpiredWatchers()
}

DisruptionsWatchersManager defines the interface for a manager that can handle adding, removing Watchers for a disruption

func NewDisruptionsWatchersManager

func NewDisruptionsWatchersManager(controller controller.Controller, factory Factory, reader client.Reader, logger *zap.SugaredLogger) DisruptionsWatchersManager

NewDisruptionsWatchersManager return a new DisruptionsWatchersManager instance

type DisruptionsWatchersManagerMock

type DisruptionsWatchersManagerMock struct {
	mock.Mock
}

DisruptionsWatchersManagerMock is an autogenerated mock type for the DisruptionsWatchersManager type

func NewDisruptionsWatchersManagerMock

func NewDisruptionsWatchersManagerMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *DisruptionsWatchersManagerMock

NewDisruptionsWatchersManagerMock creates a new instance of DisruptionsWatchersManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*DisruptionsWatchersManagerMock) CreateAllWatchers

func (_m *DisruptionsWatchersManagerMock) CreateAllWatchers(disruption *v1beta1.Disruption, watcherManagerMock Manager, cacheMock cache.Cache) error

CreateAllWatchers provides a mock function with given fields: disruption, watcherManagerMock, cacheMock

func (*DisruptionsWatchersManagerMock) EXPECT

func (*DisruptionsWatchersManagerMock) RemoveAllExpiredWatchers

func (_m *DisruptionsWatchersManagerMock) RemoveAllExpiredWatchers()

RemoveAllExpiredWatchers provides a mock function with given fields:

func (*DisruptionsWatchersManagerMock) RemoveAllOrphanWatchers

func (_m *DisruptionsWatchersManagerMock) RemoveAllOrphanWatchers() error

RemoveAllOrphanWatchers provides a mock function with given fields:

func (*DisruptionsWatchersManagerMock) RemoveAllWatchers

func (_m *DisruptionsWatchersManagerMock) RemoveAllWatchers(disruption *v1beta1.Disruption)

RemoveAllWatchers provides a mock function with given fields: disruption

type DisruptionsWatchersManagerMock_CreateAllWatchers_Call

type DisruptionsWatchersManagerMock_CreateAllWatchers_Call struct {
	*mock.Call
}

DisruptionsWatchersManagerMock_CreateAllWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateAllWatchers'

func (*DisruptionsWatchersManagerMock_CreateAllWatchers_Call) Return

func (*DisruptionsWatchersManagerMock_CreateAllWatchers_Call) Run

func (*DisruptionsWatchersManagerMock_CreateAllWatchers_Call) RunAndReturn

type DisruptionsWatchersManagerMock_Expecter

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

func (*DisruptionsWatchersManagerMock_Expecter) CreateAllWatchers

func (_e *DisruptionsWatchersManagerMock_Expecter) CreateAllWatchers(disruption interface{}, watcherManagerMock interface{}, cacheMock interface{}) *DisruptionsWatchersManagerMock_CreateAllWatchers_Call

CreateAllWatchers is a helper method to define mock.On call

  • disruption *v1beta1.Disruption
  • watcherManagerMock Manager
  • cacheMock cache.Cache

func (*DisruptionsWatchersManagerMock_Expecter) RemoveAllExpiredWatchers

RemoveAllExpiredWatchers is a helper method to define mock.On call

func (*DisruptionsWatchersManagerMock_Expecter) RemoveAllOrphanWatchers

RemoveAllOrphanWatchers is a helper method to define mock.On call

func (*DisruptionsWatchersManagerMock_Expecter) RemoveAllWatchers

RemoveAllWatchers is a helper method to define mock.On call

  • disruption *v1beta1.Disruption

type DisruptionsWatchersManagerMock_RemoveAllExpiredWatchers_Call

type DisruptionsWatchersManagerMock_RemoveAllExpiredWatchers_Call struct {
	*mock.Call
}

DisruptionsWatchersManagerMock_RemoveAllExpiredWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllExpiredWatchers'

func (*DisruptionsWatchersManagerMock_RemoveAllExpiredWatchers_Call) Return

func (*DisruptionsWatchersManagerMock_RemoveAllExpiredWatchers_Call) Run

func (*DisruptionsWatchersManagerMock_RemoveAllExpiredWatchers_Call) RunAndReturn

type DisruptionsWatchersManagerMock_RemoveAllOrphanWatchers_Call

type DisruptionsWatchersManagerMock_RemoveAllOrphanWatchers_Call struct {
	*mock.Call
}

DisruptionsWatchersManagerMock_RemoveAllOrphanWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllOrphanWatchers'

func (*DisruptionsWatchersManagerMock_RemoveAllOrphanWatchers_Call) Return

func (*DisruptionsWatchersManagerMock_RemoveAllOrphanWatchers_Call) Run

func (*DisruptionsWatchersManagerMock_RemoveAllOrphanWatchers_Call) RunAndReturn

type DisruptionsWatchersManagerMock_RemoveAllWatchers_Call

type DisruptionsWatchersManagerMock_RemoveAllWatchers_Call struct {
	*mock.Call
}

DisruptionsWatchersManagerMock_RemoveAllWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllWatchers'

func (*DisruptionsWatchersManagerMock_RemoveAllWatchers_Call) Return

func (*DisruptionsWatchersManagerMock_RemoveAllWatchers_Call) Run

func (*DisruptionsWatchersManagerMock_RemoveAllWatchers_Call) RunAndReturn

type Factory

type Factory interface {
	// NewChaosPodWatcher creates a new ChaosPodWatcher with the given name, disruption, and cache.
	NewChaosPodWatcher(name string, disruption *v1beta1.Disruption, cacheMock k8scache.Cache) (Watcher, error)

	// NewDisruptionTargetWatcher creates a new DisruptionTargetWatcher with the given name, enableObserver flag, disruption, and cache.
	NewDisruptionTargetWatcher(name string, enableObserver bool, disruption *v1beta1.Disruption, cacheMock k8scache.Cache) (Watcher, error)
}

Factory is an interface for creating Watchers.

func NewWatcherFactory

func NewWatcherFactory(config FactoryConfig) Factory

NewWatcherFactory creates a new instance of the factory for creating new watcher instances.

type FactoryConfig

type FactoryConfig struct {
	Log            *zap.SugaredLogger
	MetricSink     metrics.Sink
	Reader         client.Reader
	Recorder       record.EventRecorder
	ChaosNamespace string
}

type FactoryMock

type FactoryMock struct {
	mock.Mock
}

FactoryMock is an autogenerated mock type for the Factory type

func NewFactoryMock

func NewFactoryMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *FactoryMock

NewFactoryMock creates a new instance of FactoryMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*FactoryMock) EXPECT

func (_m *FactoryMock) EXPECT() *FactoryMock_Expecter

func (*FactoryMock) NewChaosPodWatcher

func (_m *FactoryMock) NewChaosPodWatcher(name string, disruption *v1beta1.Disruption, cacheMock cache.Cache) (Watcher, error)

NewChaosPodWatcher provides a mock function with given fields: name, disruption, cacheMock

func (*FactoryMock) NewDisruptionTargetWatcher

func (_m *FactoryMock) NewDisruptionTargetWatcher(name string, enableObserver bool, disruption *v1beta1.Disruption, cacheMock cache.Cache) (Watcher, error)

NewDisruptionTargetWatcher provides a mock function with given fields: name, enableObserver, disruption, cacheMock

type FactoryMock_Expecter

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

func (*FactoryMock_Expecter) NewChaosPodWatcher

func (_e *FactoryMock_Expecter) NewChaosPodWatcher(name interface{}, disruption interface{}, cacheMock interface{}) *FactoryMock_NewChaosPodWatcher_Call

NewChaosPodWatcher is a helper method to define mock.On call

  • name string
  • disruption *v1beta1.Disruption
  • cacheMock cache.Cache

func (*FactoryMock_Expecter) NewDisruptionTargetWatcher

func (_e *FactoryMock_Expecter) NewDisruptionTargetWatcher(name interface{}, enableObserver interface{}, disruption interface{}, cacheMock interface{}) *FactoryMock_NewDisruptionTargetWatcher_Call

NewDisruptionTargetWatcher is a helper method to define mock.On call

  • name string
  • enableObserver bool
  • disruption *v1beta1.Disruption
  • cacheMock cache.Cache

type FactoryMock_NewChaosPodWatcher_Call

type FactoryMock_NewChaosPodWatcher_Call struct {
	*mock.Call
}

FactoryMock_NewChaosPodWatcher_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewChaosPodWatcher'

func (*FactoryMock_NewChaosPodWatcher_Call) Return

func (*FactoryMock_NewChaosPodWatcher_Call) Run

func (*FactoryMock_NewChaosPodWatcher_Call) RunAndReturn

type FactoryMock_NewDisruptionTargetWatcher_Call

type FactoryMock_NewDisruptionTargetWatcher_Call struct {
	*mock.Call
}

FactoryMock_NewDisruptionTargetWatcher_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewDisruptionTargetWatcher'

func (*FactoryMock_NewDisruptionTargetWatcher_Call) Return

func (*FactoryMock_NewDisruptionTargetWatcher_Call) Run

func (*FactoryMock_NewDisruptionTargetWatcher_Call) RunAndReturn

type Manager

type Manager interface {
	// AddWatcher adds a new Watcher instance to the Manager
	AddWatcher(watcher Watcher) error

	// RemoveWatcher removes an existing Watcher instance from the Manager
	RemoveWatcher(watcher Watcher) error

	// RemoveExpiredWatchers removes all expired Watcher instances from the Manager
	RemoveExpiredWatchers()

	// GetWatcher returns the Watcher instance with the specified name
	GetWatcher(name string) Watcher

	// RemoveOrphanWatchers removes all orphan Watcher instances from the Manager
	RemoveOrphanWatchers()

	// RemoveAllWatchers remove all Watchers instances from the Manager
	RemoveAllWatchers()
}

Manager defines the interface for a manager that can handle adding, removing, and retrieving Watchers.

func NewManager

func NewManager(r client.Reader, c controller.Controller) Manager

NewManager creates a new Manager instance

type ManagerMock

type ManagerMock struct {
	mock.Mock
}

ManagerMock is an autogenerated mock type for the Manager type

func NewManagerMock

func NewManagerMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *ManagerMock

NewManagerMock creates a new instance of ManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*ManagerMock) AddWatcher

func (_m *ManagerMock) AddWatcher(watcher Watcher) error

AddWatcher provides a mock function with given fields: watcher

func (*ManagerMock) EXPECT

func (_m *ManagerMock) EXPECT() *ManagerMock_Expecter

func (*ManagerMock) GetWatcher

func (_m *ManagerMock) GetWatcher(name string) Watcher

GetWatcher provides a mock function with given fields: name

func (*ManagerMock) RemoveAllWatchers

func (_m *ManagerMock) RemoveAllWatchers()

RemoveAllWatchers provides a mock function with given fields:

func (*ManagerMock) RemoveExpiredWatchers

func (_m *ManagerMock) RemoveExpiredWatchers()

RemoveExpiredWatchers provides a mock function with given fields:

func (*ManagerMock) RemoveOrphanWatchers

func (_m *ManagerMock) RemoveOrphanWatchers()

RemoveOrphanWatchers provides a mock function with given fields:

func (*ManagerMock) RemoveWatcher

func (_m *ManagerMock) RemoveWatcher(watcher Watcher) error

RemoveWatcher provides a mock function with given fields: watcher

type ManagerMock_AddWatcher_Call

type ManagerMock_AddWatcher_Call struct {
	*mock.Call
}

ManagerMock_AddWatcher_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddWatcher'

func (*ManagerMock_AddWatcher_Call) Return

func (*ManagerMock_AddWatcher_Call) Run

func (*ManagerMock_AddWatcher_Call) RunAndReturn

type ManagerMock_Expecter

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

func (*ManagerMock_Expecter) AddWatcher

func (_e *ManagerMock_Expecter) AddWatcher(watcher interface{}) *ManagerMock_AddWatcher_Call

AddWatcher is a helper method to define mock.On call

  • watcher Watcher

func (*ManagerMock_Expecter) GetWatcher

func (_e *ManagerMock_Expecter) GetWatcher(name interface{}) *ManagerMock_GetWatcher_Call

GetWatcher is a helper method to define mock.On call

  • name string

func (*ManagerMock_Expecter) RemoveAllWatchers

RemoveAllWatchers is a helper method to define mock.On call

func (*ManagerMock_Expecter) RemoveExpiredWatchers

func (_e *ManagerMock_Expecter) RemoveExpiredWatchers() *ManagerMock_RemoveExpiredWatchers_Call

RemoveExpiredWatchers is a helper method to define mock.On call

func (*ManagerMock_Expecter) RemoveOrphanWatchers

func (_e *ManagerMock_Expecter) RemoveOrphanWatchers() *ManagerMock_RemoveOrphanWatchers_Call

RemoveOrphanWatchers is a helper method to define mock.On call

func (*ManagerMock_Expecter) RemoveWatcher

func (_e *ManagerMock_Expecter) RemoveWatcher(watcher interface{}) *ManagerMock_RemoveWatcher_Call

RemoveWatcher is a helper method to define mock.On call

  • watcher Watcher

type ManagerMock_GetWatcher_Call

type ManagerMock_GetWatcher_Call struct {
	*mock.Call
}

ManagerMock_GetWatcher_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWatcher'

func (*ManagerMock_GetWatcher_Call) Return

func (*ManagerMock_GetWatcher_Call) Run

func (*ManagerMock_GetWatcher_Call) RunAndReturn

type ManagerMock_RemoveAllWatchers_Call

type ManagerMock_RemoveAllWatchers_Call struct {
	*mock.Call
}

ManagerMock_RemoveAllWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAllWatchers'

func (*ManagerMock_RemoveAllWatchers_Call) Return

func (*ManagerMock_RemoveAllWatchers_Call) Run

func (*ManagerMock_RemoveAllWatchers_Call) RunAndReturn

type ManagerMock_RemoveExpiredWatchers_Call

type ManagerMock_RemoveExpiredWatchers_Call struct {
	*mock.Call
}

ManagerMock_RemoveExpiredWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveExpiredWatchers'

func (*ManagerMock_RemoveExpiredWatchers_Call) Return

func (*ManagerMock_RemoveExpiredWatchers_Call) Run

func (*ManagerMock_RemoveExpiredWatchers_Call) RunAndReturn

type ManagerMock_RemoveOrphanWatchers_Call

type ManagerMock_RemoveOrphanWatchers_Call struct {
	*mock.Call
}

ManagerMock_RemoveOrphanWatchers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveOrphanWatchers'

func (*ManagerMock_RemoveOrphanWatchers_Call) Return

func (*ManagerMock_RemoveOrphanWatchers_Call) Run

func (*ManagerMock_RemoveOrphanWatchers_Call) RunAndReturn

type ManagerMock_RemoveWatcher_Call

type ManagerMock_RemoveWatcher_Call struct {
	*mock.Call
}

ManagerMock_RemoveWatcher_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveWatcher'

func (*ManagerMock_RemoveWatcher_Call) Return

func (*ManagerMock_RemoveWatcher_Call) Run

func (*ManagerMock_RemoveWatcher_Call) RunAndReturn

type StatefulSetHandler

type StatefulSetHandler struct {
	Client client.Client
	// contains filtered or unexported fields
}

func NewStatefulSetHandler

func NewStatefulSetHandler(client client.Client, logger *zap.SugaredLogger) StatefulSetHandler

func (StatefulSetHandler) FetchAssociatedDisruptionRollouts

func (h StatefulSetHandler) FetchAssociatedDisruptionRollouts(statefulset *appsv1.StatefulSet) (*chaosv1beta1.DisruptionRolloutList, error)

func (StatefulSetHandler) HasAssociatedDisruptionRollout

func (h StatefulSetHandler) HasAssociatedDisruptionRollout(statefulset *appsv1.StatefulSet) (bool, error)

func (StatefulSetHandler) OnAdd

func (h StatefulSetHandler) OnAdd(obj interface{})

OnAdd is a handler function for the add of a statefulset

func (StatefulSetHandler) OnDelete

func (h StatefulSetHandler) OnDelete(_ interface{})

OnDelete is a handler function for the delete of a statefulset

func (StatefulSetHandler) OnUpdate

func (h StatefulSetHandler) OnUpdate(oldObj, newObj interface{})

OnUpdate is a handler function for the update of a statefulset

func (StatefulSetHandler) UpdateDisruptionRolloutStatus

func (h StatefulSetHandler) UpdateDisruptionRolloutStatus(statefulset *appsv1.StatefulSet, initContainersHash, containersHash map[string]string) error

type Watcher

type Watcher interface {
	// Clean cancels the context associated with the watcher, stopping the syncing of resources and freeing up resources.
	Clean()

	// GetCacheSource returns the syncing source of the watcher's cache.
	GetCacheSource() (source.SyncingSource, error)

	// GetContextTuple returns the context tuple associated with the watcher.
	GetContextTuple() (CtxTuple, error)

	// GetName returns the name of the watcher.
	GetName() string

	// IsExpired returns true if the context associated with the watcher has expired, meaning the watcher is no longer active.
	IsExpired() bool

	// Start starts the watcher by creating an informer from the watcher's cache and adding a resource event handler to the informer.
	Start() error

	// GetConfig return the current config of the Watcher instance.
	GetConfig() WatcherConfig
}

Watcher is an interface that describes the methods provided by a Kubernetes resource watcher.

func NewWatcher

func NewWatcher(config WatcherConfig, cacheMock k8scontrollercache.Cache, cacheContextMockFunc CacheContextFunc) (Watcher, error)

NewWatcher is a function that creates a new watcher instance based on the given configuration values.

type WatcherConfig

type WatcherConfig struct {
	// CacheOptions for configuring the cache.
	CacheOptions k8scontrollercache.Options

	// Handler function that will be called when an event occurs.
	Handler k8sclientcache.ResourceEventHandler

	// Log for logging.
	Log *zap.SugaredLogger

	// Name of the watcher instance.
	Name string

	// Namespace of the resource to watch.
	DisruptionNamespacedName types.NamespacedName

	// ObjectType of the object to watch.
	ObjectType client.Object
}

WatcherConfig holds configuration values used to create a new Watcher instance.

type WatcherEventType

type WatcherEventType string
const (
	WatcherAddEvent    WatcherEventType = "Add"
	WatcherUpdateEvent WatcherEventType = "Update"
	WatcherDeleteEvent WatcherEventType = "Delete"
)

type WatcherManagers

type WatcherManagers map[types.NamespacedName]Manager

WatcherManagers represents a map of Manager instances

type WatcherMetricsAdapter

type WatcherMetricsAdapter interface {
	OnChange(disruption *v1beta1.Disruption, watcherName string, pod *corev1.Pod, node *corev1.Node, okPod bool, okNode bool, event WatcherEventType)
}

WatcherMetricsAdapter is in charge of watcher metrics.

func NewWatcherMetricsAdapter

func NewWatcherMetricsAdapter(metricsSink metrics.Sink, log *zap.SugaredLogger) WatcherMetricsAdapter

NewWatcherMetricsAdapter constructor of WatcherMetricsAdapter

type WatcherMetricsAdapterMock

type WatcherMetricsAdapterMock struct {
	mock.Mock
}

WatcherMetricsAdapterMock is an autogenerated mock type for the WatcherMetricsAdapter type

func NewWatcherMetricsAdapterMock

func NewWatcherMetricsAdapterMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *WatcherMetricsAdapterMock

NewWatcherMetricsAdapterMock creates a new instance of WatcherMetricsAdapterMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*WatcherMetricsAdapterMock) EXPECT

func (*WatcherMetricsAdapterMock) OnChange

func (_m *WatcherMetricsAdapterMock) OnChange(disruption *v1beta1.Disruption, watcherName string, pod *v1.Pod, node *v1.Node, okPod bool, okNode bool, event WatcherEventType)

OnChange provides a mock function with given fields: disruption, watcherName, pod, node, okPod, okNode, event

type WatcherMetricsAdapterMock_Expecter

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

func (*WatcherMetricsAdapterMock_Expecter) OnChange

func (_e *WatcherMetricsAdapterMock_Expecter) OnChange(disruption interface{}, watcherName interface{}, pod interface{}, node interface{}, okPod interface{}, okNode interface{}, event interface{}) *WatcherMetricsAdapterMock_OnChange_Call

OnChange is a helper method to define mock.On call

  • disruption *v1beta1.Disruption
  • watcherName string
  • pod *v1.Pod
  • node *v1.Node
  • okPod bool
  • okNode bool
  • event WatcherEventType

type WatcherMetricsAdapterMock_OnChange_Call

type WatcherMetricsAdapterMock_OnChange_Call struct {
	*mock.Call
}

WatcherMetricsAdapterMock_OnChange_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'OnChange'

func (*WatcherMetricsAdapterMock_OnChange_Call) Return

func (*WatcherMetricsAdapterMock_OnChange_Call) Run

func (_c *WatcherMetricsAdapterMock_OnChange_Call) Run(run func(disruption *v1beta1.Disruption, watcherName string, pod *v1.Pod, node *v1.Node, okPod bool, okNode bool, event WatcherEventType)) *WatcherMetricsAdapterMock_OnChange_Call

func (*WatcherMetricsAdapterMock_OnChange_Call) RunAndReturn

type WatcherMock

type WatcherMock struct {
	mock.Mock
}

WatcherMock is an autogenerated mock type for the Watcher type

func NewWatcherMock

func NewWatcherMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *WatcherMock

NewWatcherMock creates a new instance of WatcherMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*WatcherMock) Clean

func (_m *WatcherMock) Clean()

Clean provides a mock function with given fields:

func (*WatcherMock) EXPECT

func (_m *WatcherMock) EXPECT() *WatcherMock_Expecter

func (*WatcherMock) GetCacheSource

func (_m *WatcherMock) GetCacheSource() (source.SyncingSource, error)

GetCacheSource provides a mock function with given fields:

func (*WatcherMock) GetConfig

func (_m *WatcherMock) GetConfig() WatcherConfig

GetConfig provides a mock function with given fields:

func (*WatcherMock) GetContextTuple

func (_m *WatcherMock) GetContextTuple() (CtxTuple, error)

GetContextTuple provides a mock function with given fields:

func (*WatcherMock) GetName

func (_m *WatcherMock) GetName() string

GetName provides a mock function with given fields:

func (*WatcherMock) IsExpired

func (_m *WatcherMock) IsExpired() bool

IsExpired provides a mock function with given fields:

func (*WatcherMock) Start

func (_m *WatcherMock) Start() error

Start provides a mock function with given fields:

type WatcherMock_Clean_Call

type WatcherMock_Clean_Call struct {
	*mock.Call
}

WatcherMock_Clean_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Clean'

func (*WatcherMock_Clean_Call) Return

func (*WatcherMock_Clean_Call) Run

func (_c *WatcherMock_Clean_Call) Run(run func()) *WatcherMock_Clean_Call

func (*WatcherMock_Clean_Call) RunAndReturn

func (_c *WatcherMock_Clean_Call) RunAndReturn(run func()) *WatcherMock_Clean_Call

type WatcherMock_Expecter

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

func (*WatcherMock_Expecter) Clean

Clean is a helper method to define mock.On call

func (*WatcherMock_Expecter) GetCacheSource

GetCacheSource is a helper method to define mock.On call

func (*WatcherMock_Expecter) GetConfig

GetConfig is a helper method to define mock.On call

func (*WatcherMock_Expecter) GetContextTuple

GetContextTuple is a helper method to define mock.On call

func (*WatcherMock_Expecter) GetName

GetName is a helper method to define mock.On call

func (*WatcherMock_Expecter) IsExpired

IsExpired is a helper method to define mock.On call

func (*WatcherMock_Expecter) Start

Start is a helper method to define mock.On call

type WatcherMock_GetCacheSource_Call

type WatcherMock_GetCacheSource_Call struct {
	*mock.Call
}

WatcherMock_GetCacheSource_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCacheSource'

func (*WatcherMock_GetCacheSource_Call) Return

func (*WatcherMock_GetCacheSource_Call) Run

func (*WatcherMock_GetCacheSource_Call) RunAndReturn

type WatcherMock_GetConfig_Call

type WatcherMock_GetConfig_Call struct {
	*mock.Call
}

WatcherMock_GetConfig_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConfig'

func (*WatcherMock_GetConfig_Call) Return

func (*WatcherMock_GetConfig_Call) Run

func (*WatcherMock_GetConfig_Call) RunAndReturn

type WatcherMock_GetContextTuple_Call

type WatcherMock_GetContextTuple_Call struct {
	*mock.Call
}

WatcherMock_GetContextTuple_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetContextTuple'

func (*WatcherMock_GetContextTuple_Call) Return

func (*WatcherMock_GetContextTuple_Call) Run

func (*WatcherMock_GetContextTuple_Call) RunAndReturn

type WatcherMock_GetName_Call

type WatcherMock_GetName_Call struct {
	*mock.Call
}

WatcherMock_GetName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetName'

func (*WatcherMock_GetName_Call) Return

func (*WatcherMock_GetName_Call) Run

func (*WatcherMock_GetName_Call) RunAndReturn

func (_c *WatcherMock_GetName_Call) RunAndReturn(run func() string) *WatcherMock_GetName_Call

type WatcherMock_IsExpired_Call

type WatcherMock_IsExpired_Call struct {
	*mock.Call
}

WatcherMock_IsExpired_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsExpired'

func (*WatcherMock_IsExpired_Call) Return

func (*WatcherMock_IsExpired_Call) Run

func (*WatcherMock_IsExpired_Call) RunAndReturn

func (_c *WatcherMock_IsExpired_Call) RunAndReturn(run func() bool) *WatcherMock_IsExpired_Call

type WatcherMock_Start_Call

type WatcherMock_Start_Call struct {
	*mock.Call
}

WatcherMock_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start'

func (*WatcherMock_Start_Call) Return

func (*WatcherMock_Start_Call) Run

func (_c *WatcherMock_Start_Call) Run(run func()) *WatcherMock_Start_Call

func (*WatcherMock_Start_Call) RunAndReturn

func (_c *WatcherMock_Start_Call) RunAndReturn(run func() error) *WatcherMock_Start_Call

type WatcherName

type WatcherName string
const (
	ChaosPodWatcherName         WatcherName = "ChaosPod"
	DisruptionTargetWatcherName WatcherName = "DisruptionTarget"
)

type Watchers

type Watchers map[string]Watcher

Watchers represents a map of Watcher instances

Jump to

Keyboard shortcuts

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