engine

package
v0.1.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NetworkManager  = NewNetworkChaosManager()
	ResourceManager = NewResourceChaosManager()
)
View Source
var ActionHandlers = map[string]ActionHandler{
	"stop":         actionStop,
	"restart":      actionRestart,
	"pause":        actionPause,
	"delay":        actionDelay,
	"loss":         actionLoss,
	"limit_cpu":    actionLimitCPU,
	"limit_memory": actionLimitMemory,
}

Functions

func CleanupAll

func CleanupAll()

func DiscoverComposeServices

func DiscoverComposeServices(cwd string) ([]string, string, error)

func EvaluateSteadyState

func EvaluateSteadyState(probes []config.SteadyStateProbe) error

EvaluateSteadyState checks the steady state probes against their sources.

func GenerateDefaultChaosConfig

func GenerateDefaultChaosConfig(services []string, outPath string) error

func GenerateTopologyTree

func GenerateTopologyTree(dir string) (*pterm.TreeNode, error)

GenerateTopologyTree analyzes the compose file and generates a pterm.TreeNode representing the blast radius based on networks and depends_on.

Types

type ActionHandler

type ActionHandler func(client *DockerClient, target string, spec config.ActionSpec) (*ContainerInfo, error)

type ChaosEngine

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

func NewChaosEngine

func NewChaosEngine(cfg *config.ChaosConfig, onEvent func(utils.EventRecord), logger *utils.ChaosLogger) *ChaosEngine

func (*ChaosEngine) Start

func (e *ChaosEngine) Start() error

func (*ChaosEngine) Status

func (e *ChaosEngine) Status() EngineStatus

func (*ChaosEngine) Stop

func (e *ChaosEngine) Stop()

type ComposeFile

type ComposeFile struct {
	Services map[string]ComposeService `yaml:"services"`
}

type ComposeService

type ComposeService struct {
	Image       string             `yaml:"image"`
	Deploy      *DeployConfig      `yaml:"deploy"`
	Restart     string             `yaml:"restart"`
	HealthCheck *HealthCheckConfig `yaml:"healthcheck"`
	Privileged  bool               `yaml:"privileged"`
	Networks    interface{}        `yaml:"networks"` // Can be list or map
}

ComposeService represents a subset of docker-compose service configuration used by the doctor for analyzing resilience.

type ContainerInfo

type ContainerInfo struct {
	ID     string            `json:"id"`
	Name   string            `json:"name"`
	Image  string            `json:"image"`
	Status string            `json:"status"`
	Ports  map[string]string `json:"ports"`
}

func Dispatch

func Dispatch(action config.ActionSpec, client *DockerClient, target string) (*ContainerInfo, error)

type DeployConfig

type DeployConfig struct {
	Replicas  int             `yaml:"replicas"`
	Resources *ResourceConfig `yaml:"resources"`
}

type DockerClient

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

func NewDockerClient

func NewDockerClient(allowedTargets []string) (*DockerClient, error)

func (*DockerClient) Close

func (d *DockerClient) Close()

func (*DockerClient) ExecCommand

func (d *DockerClient) ExecCommand(name string, cmd []string) (int, error)

func (*DockerClient) GetContainerPID

func (d *DockerClient) GetContainerPID(name string) (int, error)

func (*DockerClient) ListContainers

func (d *DockerClient) ListContainers(all bool) ([]ContainerInfo, error)

func (*DockerClient) PauseContainer

func (d *DockerClient) PauseContainer(name string) (*ContainerInfo, error)

func (*DockerClient) RestartContainer

func (d *DockerClient) RestartContainer(name string, timeout int) (*ContainerInfo, error)

func (*DockerClient) StopContainer

func (d *DockerClient) StopContainer(name string, timeout int) (*ContainerInfo, error)

func (*DockerClient) UnpauseContainer

func (d *DockerClient) UnpauseContainer(name string) (*ContainerInfo, error)

func (*DockerClient) UpdateContainerResources

func (d *DockerClient) UpdateContainerResources(name string, cpuQuota int64, cpuPeriod int64, memLimit int64) (*ContainerInfo, error)

type DoctorIssue

type DoctorIssue struct {
	Severity string // "CRITICAL", "WARNING"
	Category string // "SPOF", "RESOURCES", "RECOVERY", "OBSERVABILITY", "SECURITY"
	Message  string
}

DoctorIssue represents a single resilience issue found in a service

type DoctorResult

type DoctorResult struct {
	ServiceName string
	Issues      []DoctorIssue
}

DoctorResult represents the analysis result for a specific service

func AnalyzeTopology

func AnalyzeTopology(dir string) ([]DoctorResult, error)

AnalyzeTopology reads docker-compose.yml from the given directory and analyzes it for resilience anti-patterns.

type EngineStatus

type EngineStatus struct {
	Running           bool
	Config            *config.ChaosConfig
	CycleCount        int
	DownContainers    []string
	LastEvent         *utils.EventRecord
	History           []utils.EventRecord
	LastInjectionTime time.Time
	CooldownRemaining float64
}

type HealthCheckConfig

type HealthCheckConfig struct {
	Test    interface{} `yaml:"test"` // can be string or list
	Disable bool        `yaml:"disable"`
}

type NetworkChaosManager

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

func NewNetworkChaosManager

func NewNetworkChaosManager() *NetworkChaosManager

func (*NetworkChaosManager) Clear

func (m *NetworkChaosManager) Clear(name string, pid *int)

func (*NetworkChaosManager) ClearAll

func (m *NetworkChaosManager) ClearAll()

func (*NetworkChaosManager) InjectDelay

func (m *NetworkChaosManager) InjectDelay(name string, pid int, latencyMs int, jitterMs int, duration *int) error

func (*NetworkChaosManager) InjectLoss

func (m *NetworkChaosManager) InjectLoss(name string, pid int, percent int, duration *int) error

type ProbeResult

type ProbeResult struct {
	Success bool
	Message string
}

func RunProbe

func RunProbe(spec *config.ProbeSpec, dc *DockerClient) ProbeResult

type PrometheusResponse

type PrometheusResponse struct {
	Status string `json:"status"`
	Data   struct {
		ResultType string `json:"resultType"`
		Result     []struct {
			Value []interface{} `json:"value"`
		} `json:"result"`
	} `json:"data"`
}

type ResourceChaosManager

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

func NewResourceChaosManager

func NewResourceChaosManager() *ResourceChaosManager

func (*ResourceChaosManager) ClearAll

func (m *ResourceChaosManager) ClearAll()

func (*ResourceChaosManager) ScheduleRestore

func (m *ResourceChaosManager) ScheduleRestore(client *DockerClient, target string, duration int)

type ResourceConfig

type ResourceConfig struct {
	Limits *ResourceLimits `yaml:"limits"`
}

type ResourceLimits

type ResourceLimits struct {
	CPUs   string `yaml:"cpus"`
	Memory string `yaml:"memory"`
}

type ScenarioResult

type ScenarioResult struct {
	Success           bool
	ProbesPassed      int
	ProbesTotal       int
	SteadyStatePassed int
	SteadyStateTotal  int
	ExecutedSteps     int
	TotalSteps        int
	Error             string
	SteadyStateError  string
}

type ScenarioRunner

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

func NewScenarioRunner

func NewScenarioRunner(cfg *config.ScenarioConfig, logCb func(string)) *ScenarioRunner

func (*ScenarioRunner) RevertAll

func (r *ScenarioRunner) RevertAll()

func (*ScenarioRunner) Run

func (r *ScenarioRunner) Run() ScenarioResult

type TopologyNode

type TopologyNode struct {
	Name      string
	Networks  []string
	DependsOn []string
}

Jump to

Keyboard shortcuts

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