injector

package
v0.0.0-...-1e8dc9b Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 38 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.

Index

Constants

View Source
const (
	ChaosInjectorBinaryLocation = "/usr/local/bin/chaos-injector"

	ParentPIDFlag flag = "parent-pid"
	DeadlineFlag  flag = "deadline"
)
View Source
const EBPFDiskFailureCmd = "bpf-disk-failure"

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUStressArgsBuilder

type CPUStressArgsBuilder interface {
	GenerateArgs(int) []string
}

type CPUStressArgsBuilderMock

type CPUStressArgsBuilderMock struct {
	mock.Mock
}

CPUStressArgsBuilderMock is an autogenerated mock type for the CPUStressArgsBuilder type

func NewCPUStressArgsBuilderMock

func NewCPUStressArgsBuilderMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *CPUStressArgsBuilderMock

NewCPUStressArgsBuilderMock creates a new instance of CPUStressArgsBuilderMock. 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 (*CPUStressArgsBuilderMock) EXPECT

func (*CPUStressArgsBuilderMock) GenerateArgs

func (_m *CPUStressArgsBuilderMock) GenerateArgs(_a0 int) []string

GenerateArgs provides a mock function with given fields: _a0

type CPUStressArgsBuilderMock_Expecter

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

func (*CPUStressArgsBuilderMock_Expecter) GenerateArgs

GenerateArgs is a helper method to define mock.On call

  • _a0 int

type CPUStressArgsBuilderMock_GenerateArgs_Call

type CPUStressArgsBuilderMock_GenerateArgs_Call struct {
	*mock.Call
}

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

func (*CPUStressArgsBuilderMock_GenerateArgs_Call) Return

func (*CPUStressArgsBuilderMock_GenerateArgs_Call) Run

func (*CPUStressArgsBuilderMock_GenerateArgs_Call) RunAndReturn

type Config

type Config struct {
	Log                *zap.SugaredLogger
	MetricsSink        metrics.Sink
	TargetContainer    container.Container
	DisruptionDeadline time.Time
	Cgroup             cgroup.Manager
	Netns              netns.Manager
	K8sClient          kubernetes.Interface
	DNS                network.DNSConfig
	Disruption         chaosapi.DisruptionArgs
	InjectorCtx        context.Context
}

Config represents a generic injector config

func (Config) TargetName

func (c Config) TargetName() string

TargetName returns the name of the target that relates to this configuration node name if the disruption if at the node level target container name if available UnknownTargetName otherwise

type ContainerFailureInjectorConfig

type ContainerFailureInjectorConfig struct {
	Config
	ProcessManager process.Manager
}

ContainerFailureInjectorConfig contains needed drivers to create a ContainerFailureInjector

type DNSDisruptionInjector

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

DNSDisruptionInjector describes a dns disruption

func (*DNSDisruptionInjector) Clean

func (i *DNSDisruptionInjector) Clean() error

Clean removes the injected disruption from the given container

func (*DNSDisruptionInjector) GetDisruptionKind

func (i *DNSDisruptionInjector) GetDisruptionKind() chaostypes.DisruptionKindName

func (*DNSDisruptionInjector) Inject

func (i *DNSDisruptionInjector) Inject() error

Inject injects the given dns disruption into the given container

func (*DNSDisruptionInjector) TargetName

func (i *DNSDisruptionInjector) TargetName() string

func (*DNSDisruptionInjector) UpdateConfig

func (i *DNSDisruptionInjector) UpdateConfig(config Config)

type DNSDisruptionInjectorConfig

type DNSDisruptionInjectorConfig struct {
	Config
	DisruptionName      string
	DisruptionNamespace string
	TargetName          string
	FileWriter          FileWriter
	IPTables            network.IPTables
	CmdFactory          command.Factory
	ProcessManager      process.Manager
}

DNSDisruptionInjectorConfig contains all needed drivers to create a dns disruption using `iptables`

type DiskFailureInjector

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

func (*DiskFailureInjector) Clean

func (i *DiskFailureInjector) Clean() error

func (*DiskFailureInjector) GetDisruptionKind

func (i *DiskFailureInjector) GetDisruptionKind() types.DisruptionKindName

func (*DiskFailureInjector) Inject

func (i *DiskFailureInjector) Inject() error

func (*DiskFailureInjector) TargetName

func (i *DiskFailureInjector) TargetName() string

func (*DiskFailureInjector) UpdateConfig

func (i *DiskFailureInjector) UpdateConfig(config Config)

type DiskFailureInjectorConfig

type DiskFailureInjectorConfig struct {
	Config
	CmdFactory        command.Factory
	ProcessManager    process.Manager
	BPFConfigInformer ebpf.ConfigInformer
}

DiskFailureInjectorConfig is the disk pressure injector config

type DiskPressureInjectorConfig

type DiskPressureInjectorConfig struct {
	Config
	Informer disk.Informer
}

DiskPressureInjectorConfig is the disk pressure injector config

type FileWriter

type FileWriter interface {
	Write(path string, mode os.FileMode, data string) error
}

FileWriter is a component allowing to write the given data to the given file

type FileWriterMock

type FileWriterMock struct {
	mock.Mock
}

FileWriterMock is an autogenerated mock type for the FileWriter type

func NewFileWriterMock

func NewFileWriterMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *FileWriterMock

NewFileWriterMock creates a new instance of FileWriterMock. 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 (*FileWriterMock) EXPECT

func (*FileWriterMock) Write

func (_m *FileWriterMock) Write(path string, mode fs.FileMode, data string) error

Write provides a mock function with given fields: path, mode, data

type FileWriterMock_Expecter

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

func (*FileWriterMock_Expecter) Write

func (_e *FileWriterMock_Expecter) Write(path interface{}, mode interface{}, data interface{}) *FileWriterMock_Write_Call

Write is a helper method to define mock.On call

  • path string
  • mode fs.FileMode
  • data string

type FileWriterMock_Write_Call

type FileWriterMock_Write_Call struct {
	*mock.Call
}

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

func (*FileWriterMock_Write_Call) Return

func (*FileWriterMock_Write_Call) Run

func (_c *FileWriterMock_Write_Call) Run(run func(path string, mode fs.FileMode, data string)) *FileWriterMock_Write_Call

func (*FileWriterMock_Write_Call) RunAndReturn

type GRPCDisruptionInjector

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

GRPCDisruptionInjector describes a grpc disruption

func (*GRPCDisruptionInjector) Clean

func (i *GRPCDisruptionInjector) Clean() error

Clean removes the injected disruption from the given container

func (*GRPCDisruptionInjector) GetDisruptionKind

func (i *GRPCDisruptionInjector) GetDisruptionKind() types.DisruptionKindName

func (*GRPCDisruptionInjector) Inject

func (i *GRPCDisruptionInjector) Inject() error

Inject injects the given grpc disruption into the given container

func (*GRPCDisruptionInjector) TargetName

func (i *GRPCDisruptionInjector) TargetName() string

func (*GRPCDisruptionInjector) UpdateConfig

func (i *GRPCDisruptionInjector) UpdateConfig(config Config)

type GRPCDisruptionInjectorConfig

type GRPCDisruptionInjectorConfig struct {
	Config
	State InjectorState
}

GRPCDisruptionInjectorConfig contains all needed drivers to create a grpc disruption

type Injector

type Injector interface {
	GetDisruptionKind() types.DisruptionKindName
	Inject() error
	TargetName() string
	UpdateConfig(config Config)
	Clean() error
}

Injector is an interface being able to inject or clean disruptions

func NewCPUPressureInjector

func NewCPUPressureInjector(config Config, count string, injectorCmdFactory InjectorCmdFactory, argsBuilder CPUStressArgsBuilder) Injector

NewCPUPressureInjector creates a CPU pressure injector with the given config

func NewCPUStressInjector

func NewCPUStressInjector(config Config, percentage int, process process.Manager, runtime process.Runtime) Injector

NewCPUPressureInjector creates a CPU pressure injector with the given config

func NewContainerFailureInjector

func NewContainerFailureInjector(spec v1beta1.ContainerFailureSpec, config ContainerFailureInjectorConfig) Injector

NewContainerFailureInjector creates a ContainerFailureInjector object with the given config, missing fields being initialized with the defaults

func NewDNSDisruptionInjector

func NewDNSDisruptionInjector(spec v1beta1.DNSDisruptionSpec, config DNSDisruptionInjectorConfig) (Injector, error)

NewDNSDisruptionInjector creates a DNSDisruptionInjector object with the given config, missing fields are initialized with the defaults

func NewDiskFailureInjector

func NewDiskFailureInjector(spec v1beta1.DiskFailureSpec, config DiskFailureInjectorConfig) (Injector, error)

NewDiskFailureInjector creates a disk failure injector with the given config

func NewDiskPressureInjector

func NewDiskPressureInjector(spec v1beta1.DiskPressureSpec, config DiskPressureInjectorConfig) (Injector, error)

NewDiskPressureInjector creates a disk pressure injector with the given config

func NewGRPCDisruptionInjector

func NewGRPCDisruptionInjector(spec v1beta1.GRPCDisruptionSpec, config GRPCDisruptionInjectorConfig) Injector

NewGRPCDisruptionInjector creates a GRPCDisruptionInjector object with the given config, missing fields are initialized with the defaults

func NewNetworkDisruptionInjector

func NewNetworkDisruptionInjector(spec v1beta1.NetworkDisruptionSpec, config NetworkDisruptionInjectorConfig) (Injector, error)

NewNetworkDisruptionInjector creates a NetworkDisruptionInjector object with the given config, missing field being initialized with the defaults

func NewNodeFailureInjector

func NewNodeFailureInjector(spec v1beta1.NodeFailureSpec, config NodeFailureInjectorConfig) (Injector, error)

NewNodeFailureInjector creates a NodeFailureInjector object with the given config, missing fields being initialized with the defaults

type InjectorCmdFactory

type InjectorCmdFactory interface {
	NewInjectorBackgroundCmd(deadline time.Time, disruptionArgs chaosapi.DisruptionArgs, target string, args []string) (command.BackgroundCmd, context.CancelFunc, error)
}

func NewInjectorCmdFactory

func NewInjectorCmdFactory(log *zap.SugaredLogger, processManager process.Manager, cmdBuilder command.Factory) InjectorCmdFactory

type InjectorCmdFactoryMock

type InjectorCmdFactoryMock struct {
	mock.Mock
}

InjectorCmdFactoryMock is an autogenerated mock type for the InjectorCmdFactory type

func NewInjectorCmdFactoryMock

func NewInjectorCmdFactoryMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *InjectorCmdFactoryMock

NewInjectorCmdFactoryMock creates a new instance of InjectorCmdFactoryMock. 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 (*InjectorCmdFactoryMock) EXPECT

func (*InjectorCmdFactoryMock) NewInjectorBackgroundCmd

func (_m *InjectorCmdFactoryMock) NewInjectorBackgroundCmd(deadline time.Time, disruptionArgs api.DisruptionArgs, target string, args []string) (command.BackgroundCmd, context.CancelFunc, error)

NewInjectorBackgroundCmd provides a mock function with given fields: deadline, disruptionArgs, target, args

type InjectorCmdFactoryMock_Expecter

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

func (*InjectorCmdFactoryMock_Expecter) NewInjectorBackgroundCmd

func (_e *InjectorCmdFactoryMock_Expecter) NewInjectorBackgroundCmd(deadline interface{}, disruptionArgs interface{}, target interface{}, args interface{}) *InjectorCmdFactoryMock_NewInjectorBackgroundCmd_Call

NewInjectorBackgroundCmd is a helper method to define mock.On call

  • deadline time.Time
  • disruptionArgs api.DisruptionArgs
  • target string
  • args []string

type InjectorCmdFactoryMock_NewInjectorBackgroundCmd_Call

type InjectorCmdFactoryMock_NewInjectorBackgroundCmd_Call struct {
	*mock.Call
}

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

func (*InjectorCmdFactoryMock_NewInjectorBackgroundCmd_Call) Return

func (*InjectorCmdFactoryMock_NewInjectorBackgroundCmd_Call) Run

type InjectorMock

type InjectorMock struct {
	mock.Mock
}

InjectorMock is an autogenerated mock type for the Injector type

func NewInjectorMock

func NewInjectorMock(t interface {
	mock.TestingT
	Cleanup(func())
}) *InjectorMock

NewInjectorMock creates a new instance of InjectorMock. 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 (*InjectorMock) Clean

func (_m *InjectorMock) Clean() error

Clean provides a mock function with given fields:

func (*InjectorMock) EXPECT

func (_m *InjectorMock) EXPECT() *InjectorMock_Expecter

func (*InjectorMock) GetDisruptionKind

func (_m *InjectorMock) GetDisruptionKind() types.DisruptionKindName

GetDisruptionKind provides a mock function with given fields:

func (*InjectorMock) Inject

func (_m *InjectorMock) Inject() error

Inject provides a mock function with given fields:

func (*InjectorMock) TargetName

func (_m *InjectorMock) TargetName() string

TargetName provides a mock function with given fields:

func (*InjectorMock) UpdateConfig

func (_m *InjectorMock) UpdateConfig(config Config)

UpdateConfig provides a mock function with given fields: config

type InjectorMock_Clean_Call

type InjectorMock_Clean_Call struct {
	*mock.Call
}

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

func (*InjectorMock_Clean_Call) Return

func (*InjectorMock_Clean_Call) Run

func (_c *InjectorMock_Clean_Call) Run(run func()) *InjectorMock_Clean_Call

func (*InjectorMock_Clean_Call) RunAndReturn

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

type InjectorMock_Expecter

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

func (*InjectorMock_Expecter) Clean

Clean is a helper method to define mock.On call

func (*InjectorMock_Expecter) GetDisruptionKind

GetDisruptionKind is a helper method to define mock.On call

func (*InjectorMock_Expecter) Inject

Inject is a helper method to define mock.On call

func (*InjectorMock_Expecter) TargetName

TargetName is a helper method to define mock.On call

func (*InjectorMock_Expecter) UpdateConfig

func (_e *InjectorMock_Expecter) UpdateConfig(config interface{}) *InjectorMock_UpdateConfig_Call

UpdateConfig is a helper method to define mock.On call

  • config Config

type InjectorMock_GetDisruptionKind_Call

type InjectorMock_GetDisruptionKind_Call struct {
	*mock.Call
}

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

func (*InjectorMock_GetDisruptionKind_Call) Return

func (*InjectorMock_GetDisruptionKind_Call) Run

func (*InjectorMock_GetDisruptionKind_Call) RunAndReturn

type InjectorMock_Inject_Call

type InjectorMock_Inject_Call struct {
	*mock.Call
}

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

func (*InjectorMock_Inject_Call) Return

func (*InjectorMock_Inject_Call) Run

func (*InjectorMock_Inject_Call) RunAndReturn

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

type InjectorMock_TargetName_Call

type InjectorMock_TargetName_Call struct {
	*mock.Call
}

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

func (*InjectorMock_TargetName_Call) Return

func (*InjectorMock_TargetName_Call) Run

func (*InjectorMock_TargetName_Call) RunAndReturn

type InjectorMock_UpdateConfig_Call

type InjectorMock_UpdateConfig_Call struct {
	*mock.Call
}

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

func (*InjectorMock_UpdateConfig_Call) Return

func (*InjectorMock_UpdateConfig_Call) Run

func (*InjectorMock_UpdateConfig_Call) RunAndReturn

type InjectorState

type InjectorState string
const (
	Created           InjectorState = "created"
	Injected          InjectorState = "injected"
	Cleaned           InjectorState = "cleaned"
	UnknownTargetName               = "unknown target name"
)

type NetworkDisruptionInjectorConfig

type NetworkDisruptionInjectorConfig struct {
	Config
	TrafficController   network.TrafficController
	IPTables            network.IPTables
	NetlinkAdapter      network.NetlinkAdapter
	DNSClient           network.DNSClient
	HostResolveInterval time.Duration
	BPFConfigInformer   ebpf.ConfigInformer
}

NetworkDisruptionInjectorConfig contains all needed drivers to create a network disruption using `tc`

type NodeFailureInjectorConfig

type NodeFailureInjectorConfig struct {
	Config
	FileWriter         FileWriter
	WaitBeforeShutdown time.Duration
}

NodeFailureInjectorConfig contains needed drivers to create a NodeFailureInjector

Jump to

Keyboard shortcuts

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