disruptors

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package disruptors implements an API for disrupting targets

Index

Constants

View Source
const DefaultTargetPort = 80

DefaultTargetPort defines default target port if not specified in Fault

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentController

type AgentController interface {
	// InjectDisruptorAgent injects the Disruptor agent in the target pods
	InjectDisruptorAgent(ctx context.Context) error
	// ExecCommand executes a command in the targets of the AgentController and reports any error
	ExecCommand(ctx context.Context, cmd []string) error
	// Targets retrieves the names of the target of the controller
	Targets(ctx context.Context) ([]string, error)
	// Visit allows executing a different command on each target returned by a visiting function
	Visit(ctx context.Context, visitor func(target corev1.Pod) ([]string, error)) error
}

AgentController defines the interface for controlling agents in a set of targets

func NewAgentController added in v0.2.0

func NewAgentController(
	_ context.Context,
	helper helpers.PodHelper,
	namespace string,
	targets []corev1.Pod,
	timeout time.Duration,
) AgentController

NewAgentController creates a new controller for a list of target pods

type Disruptor added in v0.3.1

type Disruptor interface {
	// Targets returns the names of the targets for the disruptor
	Targets(ctx context.Context) ([]string, error)
}

Disruptor defines the generic interface implemented by all disruptors

type GrpcDisruptionOptions added in v0.2.0

type GrpcDisruptionOptions struct {
	// Port used by the agent for listening
	ProxyPort uint `js:"proxyPort"`
}

GrpcDisruptionOptions defines options for the injection of grpc faults in a target pod

type GrpcFault added in v0.2.0

type GrpcFault struct {
	// port the disruptions will be applied to
	Port uint
	// Average delay introduced to requests
	AverageDelay time.Duration `js:"averageDelay"`
	// Variation in the delay (with respect of the average delay)
	DelayVariation time.Duration `js:"delayVariation"`
	// Fraction (in the range 0.0 to 1.0) of requests that will return an error
	ErrorRate float32 `js:"errorRate"`
	// Status code to be returned by requests selected to return an error
	StatusCode int32 `js:"statusCode"`
	// Status message to be returned in requests selected to return an error
	StatusMessage string `js:"statusMessage"`
	// List of grpc services to be excluded from disruptions
	Exclude string `js:"exclude"`
}

GrpcFault specifies a fault to be injected in grpc requests

type HTTPDisruptionOptions

type HTTPDisruptionOptions struct {
	// Port used by the agent for listening
	ProxyPort uint `js:"proxyPort"`
}

HTTPDisruptionOptions defines options for the injection of HTTP faults in a target pod

type HTTPFault

type HTTPFault struct {
	// port the disruptions will be applied to
	Port uint
	// Average delay introduced to requests
	AverageDelay time.Duration `js:"averageDelay"`
	// Variation in the delay (with respect of the average delay)
	DelayVariation time.Duration `js:"delayVariation"`
	// Fraction (in the range 0.0 to 1.0) of requests that will return an error
	ErrorRate float32 `js:"errorRate"`
	// Error code to be returned by requests selected in the error rate
	ErrorCode uint `js:"errorCode"`
	// Body to be returned when an error is injected
	ErrorBody string `js:"errorBody"`
	// Comma-separated list of url paths to be excluded from disruptions
	Exclude string
}

HTTPFault specifies a fault to be injected in http requests

type PodAttributes

type PodAttributes struct {
	Labels map[string]string
}

PodAttributes defines the attributes a Pod must match for being selected/excluded

type PodDisruptor

type PodDisruptor interface {
	Disruptor
	ProtocolFaultInjector
}

PodDisruptor defines the types of faults that can be injected in a Pod

func NewPodDisruptor

func NewPodDisruptor(
	ctx context.Context,
	k8s kubernetes.Kubernetes,
	selector PodSelector,
	options PodDisruptorOptions,
) (PodDisruptor, error)

NewPodDisruptor creates a new instance of a PodDisruptor that acts on the pods that match the given PodSelector

type PodDisruptorOptions

type PodDisruptorOptions struct {
	// timeout when waiting agent to be injected in seconds. A zero value forces default.
	// A Negative value forces no waiting.
	InjectTimeout time.Duration `js:"injectTimeout"`
}

PodDisruptorOptions defines options that controls the PodDisruptor's behavior

type PodSelector

type PodSelector struct {
	Namespace string
	// Select Pods that match these PodAttributes
	Select PodAttributes
	// Select Pods that match these PodAttributes
	Exclude PodAttributes
}

PodSelector defines the criteria for selecting a pod for disruption

type ProtocolFaultInjector added in v0.3.1

type ProtocolFaultInjector interface {
	// InjectHTTPFault injects faults in the HTTP requests sent to the disruptor's targets
	// for the specified duration
	InjectHTTPFaults(ctx context.Context, fault HTTPFault, duration time.Duration, options HTTPDisruptionOptions) error
	// InjectGrpcFault injects faults in the grpc requests sent to the disruptor's targets
	// for the specified duration
	InjectGrpcFaults(ctx context.Context, fault GrpcFault, duration time.Duration, options GrpcDisruptionOptions) error
}

ProtocolFaultInjector defines the methods for injecting protocol faults

type ServiceDisruptor

type ServiceDisruptor interface {
	Disruptor
	ProtocolFaultInjector
}

ServiceDisruptor defines operations for injecting faults in services

func NewServiceDisruptor

func NewServiceDisruptor(
	ctx context.Context,
	k8s kubernetes.Kubernetes,
	service string,
	namespace string,
	options ServiceDisruptorOptions,
) (ServiceDisruptor, error)

NewServiceDisruptor creates a new instance of a ServiceDisruptor that targets the given service

type ServiceDisruptorOptions

type ServiceDisruptorOptions struct {
	// timeout when waiting agent to be injected (default 30s). A zero value forces default.
	// A Negative value forces no waiting.
	InjectTimeout time.Duration `js:"injectTimeout"`
}

ServiceDisruptorOptions defines options that controls the behavior of the ServiceDisruptor

Jump to

Keyboard shortcuts

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