Documentation
¶
Index ¶
- func ChaosObjectExists(object client.Object, c client.Client) (bool, error)
- func NewChaosMeshClient() (client.Client, error)
- func Ptr[T any](value T) *T
- func WaitForAllChaosRunning(chaosObjects []*Chaos, timeoutDuration time.Duration) error
- type Chaos
- func (c *Chaos) AddListener(listener ChaosListener)
- func (c *Chaos) Create(ctx context.Context)
- func (c *Chaos) Delete(ctx context.Context) error
- func (c *Chaos) GetChaosDescription() string
- func (c *Chaos) GetChaosDuration() (time.Duration, error)
- func (c *Chaos) GetChaosEvents() (*corev1.EventList, error)
- func (c *Chaos) GetChaosKind() string
- func (c *Chaos) GetChaosName() string
- func (c *Chaos) GetChaosSpec() interface{}
- func (c *Chaos) GetChaosStatus() (*v1alpha1.ChaosStatus, error)
- func (c *Chaos) GetChaosTypeStr() string
- func (c *Chaos) GetEndTime() time.Time
- func (c *Chaos) GetExpectedEndTime() (time.Time, error)
- func (c *Chaos) GetExperimentStatus() (v1alpha1.ExperimentStatus, error)
- func (c *Chaos) GetObject() client.Object
- func (c *Chaos) GetStartTime() time.Time
- func (c *Chaos) Pause(ctx context.Context) error
- func (c *Chaos) Resume(ctx context.Context) error
- func (c *Chaos) Update(ctx context.Context) error
- type ChaosEntity
- type ChaosEventDetails
- type ChaosListener
- type ChaosLogger
- func (l ChaosLogger) OnChaosCreated(chaos Chaos)
- func (l ChaosLogger) OnChaosCreationFailed(chaos Chaos, reason error)
- func (l ChaosLogger) OnChaosDeleted(chaos Chaos)
- func (l ChaosLogger) OnChaosEnded(chaos Chaos)
- func (l ChaosLogger) OnChaosPaused(chaos Chaos)
- func (l ChaosLogger) OnChaosStarted(chaos Chaos)
- func (l ChaosLogger) OnChaosStatusUnknown(chaos Chaos)
- type ChaosOpts
- type ChaosStatus
- type NamespaceScopedChaosRunner
- func (cr *NamespaceScopedChaosRunner) RunPodCorrupt(ctx context.Context, cfg PodCorruptCfg) (*Chaos, error)
- func (cr *NamespaceScopedChaosRunner) RunPodDelay(ctx context.Context, cfg PodDelayCfg) (*Chaos, error)
- func (cr *NamespaceScopedChaosRunner) RunPodFail(ctx context.Context, cfg PodFailCfg) (*Chaos, error)
- func (cr *NamespaceScopedChaosRunner) RunPodLoss(ctx context.Context, cfg PodLossCfg) (*Chaos, error)
- func (cr *NamespaceScopedChaosRunner) RunPodPartition(ctx context.Context, cfg PodPartitionCfg) (*Chaos, error)
- func (cr *NamespaceScopedChaosRunner) RunPodStressCPU(ctx context.Context, cfg NodeCPUStressConfig) (*Chaos, error)
- type NetworkChaosOpts
- type NodeCPUStressConfig
- type PodChaosOpts
- type PodCorruptCfg
- type PodDelayCfg
- type PodFailCfg
- type PodLossCfg
- type PodPartitionCfg
- type RangeGrafanaAnnotator
- func (l RangeGrafanaAnnotator) OnChaosCreated(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosCreationFailed(chaos Chaos, reason error)
- func (l RangeGrafanaAnnotator) OnChaosEnded(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosPaused(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosStarted(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosStatusUnknown(chaos Chaos)
- type SimplifiedEvent
- type SingleLineGrafanaAnnotator
- func (l SingleLineGrafanaAnnotator) OnChaosCreated(chaos Chaos)
- func (l SingleLineGrafanaAnnotator) OnChaosCreationFailed(chaos Chaos, reason error)
- func (l SingleLineGrafanaAnnotator) OnChaosEnded(chaos Chaos)
- func (l SingleLineGrafanaAnnotator) OnChaosPaused(chaos Chaos)
- func (l SingleLineGrafanaAnnotator) OnChaosStarted(chaos Chaos)
- func (l SingleLineGrafanaAnnotator) OnChaosStatusUnknown(chaos Chaos)
- type StressChaosOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChaosObjectExists ¶
func NewChaosMeshClient ¶
NewChaosMeshClient initializes and returns a new Kubernetes client configured for Chaos Mesh
Types ¶
type Chaos ¶
type Chaos struct {
Object client.Object
Description string
DelayCreate time.Duration // Delay before creating the chaos object
Status ChaosStatus
Client client.Client
// contains filtered or unexported fields
}
func NewChaos ¶
NewChaos creates a new Chaos instance based on the provided options. It requires a client, a chaos object, and a logger to function properly. This function is essential for initializing chaos experiments in a Kubernetes environment.
func (*Chaos) AddListener ¶
func (c *Chaos) AddListener(listener ChaosListener)
func (*Chaos) Create ¶
Create initiates a delayed creation of a chaos object, respecting context cancellation and deletion requests. It uses a timer based on `DelayCreate` and calls `create` method upon expiration unless preempted by deletion.
func (*Chaos) Delete ¶
Delete stops the chaos operation, updates its status, and removes the chaos object if specified. It notifies listeners of the operation's completion and handles any errors encountered during the process.
func (*Chaos) GetChaosDescription ¶
func (*Chaos) GetChaosKind ¶
func (*Chaos) GetChaosName ¶
func (*Chaos) GetChaosSpec ¶
func (c *Chaos) GetChaosSpec() interface{}
func (*Chaos) GetChaosStatus ¶
func (c *Chaos) GetChaosStatus() (*v1alpha1.ChaosStatus, error)
func (*Chaos) GetChaosTypeStr ¶
func (*Chaos) GetEndTime ¶
GetEndTime returns the time when the chaos experiment ended
func (*Chaos) GetExpectedEndTime ¶
GetExpectedEndTime returns the time when the chaos experiment is expected to end
func (*Chaos) GetExperimentStatus ¶
func (c *Chaos) GetExperimentStatus() (v1alpha1.ExperimentStatus, error)
func (*Chaos) GetStartTime ¶
GetStartTime returns the time when the chaos experiment started
type ChaosEntity ¶
type ChaosEntity interface {
// Create initializes and submits the chaos object to Kubernetes.
Create(ctx context.Context)
// Delete removes the chaos object from Kubernetes.
Delete(ctx context.Context) error
// Registers a listener to receive updates about the chaos object's lifecycle.
AddListener(listener ChaosListener)
GetObject() client.Object
GetChaosName() string
GetChaosDescription() string
GetChaosDuration() (time.Duration, error)
GetChaosSpec() interface{}
GetStartTime() time.Time
GetEndTime() time.Time
GetExpectedEndTime() (time.Time, error)
}
ChaosEntity is an interface that defines common behaviors for chaos management entities.
type ChaosEventDetails ¶
type ChaosListener ¶
type ChaosListener interface {
OnChaosCreated(chaos Chaos)
OnChaosCreationFailed(chaos Chaos, reason error)
OnChaosStarted(chaos Chaos)
OnChaosPaused(chaos Chaos)
OnChaosEnded(chaos Chaos) // When the chaos is finished or deleted
OnChaosStatusUnknown(chaos Chaos) // When the chaos status is unknown
}
ChaosListener is an interface that can be implemented by clients to listen to and react to chaos events.
type ChaosLogger ¶
type ChaosLogger struct {
// contains filtered or unexported fields
}
func NewChaosLogger ¶
func NewChaosLogger(logger zerolog.Logger) *ChaosLogger
func (ChaosLogger) OnChaosCreated ¶
func (l ChaosLogger) OnChaosCreated(chaos Chaos)
func (ChaosLogger) OnChaosCreationFailed ¶
func (l ChaosLogger) OnChaosCreationFailed(chaos Chaos, reason error)
func (ChaosLogger) OnChaosDeleted ¶
func (l ChaosLogger) OnChaosDeleted(chaos Chaos)
func (ChaosLogger) OnChaosEnded ¶
func (l ChaosLogger) OnChaosEnded(chaos Chaos)
func (ChaosLogger) OnChaosPaused ¶
func (l ChaosLogger) OnChaosPaused(chaos Chaos)
func (ChaosLogger) OnChaosStarted ¶
func (l ChaosLogger) OnChaosStarted(chaos Chaos)
func (ChaosLogger) OnChaosStatusUnknown ¶
func (l ChaosLogger) OnChaosStatusUnknown(chaos Chaos)
type ChaosStatus ¶
type ChaosStatus string
ChaosStatus represents the status of a chaos experiment.
const ( StatusCreated ChaosStatus = "created" StatusCreationFailed ChaosStatus = "creation_failed" StatusRunning ChaosStatus = "running" StatusPaused ChaosStatus = "paused" StatusFinished ChaosStatus = "finished" StatusDeleted ChaosStatus = "deleted" StatusUnknown ChaosStatus = "unknown" // For any state that doesn't match the above )
These constants define possible states of a chaos experiment.
type NamespaceScopedChaosRunner ¶
type NamespaceScopedChaosRunner struct {
// contains filtered or unexported fields
}
func NewNamespaceRunner ¶
NewNamespaceRunner creates a new namespace-scoped chaos runner
func (*NamespaceScopedChaosRunner) RunPodCorrupt ¶
func (cr *NamespaceScopedChaosRunner) RunPodCorrupt(ctx context.Context, cfg PodCorruptCfg) (*Chaos, error)
RunPodCorrupt initiates packet corruption for some pod in some namespace
func (*NamespaceScopedChaosRunner) RunPodDelay ¶
func (cr *NamespaceScopedChaosRunner) RunPodDelay(ctx context.Context, cfg PodDelayCfg) (*Chaos, error)
RunPodDelay initiates a network delay chaos experiment on specified pods. It configures the delay parameters and applies them to the targeted namespace. This function is useful for testing the resilience of applications under network latency conditions.
func (*NamespaceScopedChaosRunner) RunPodFail ¶
func (cr *NamespaceScopedChaosRunner) RunPodFail(ctx context.Context, cfg PodFailCfg) (*Chaos, error)
RunPodFail initiates a pod failure experiment based on the provided configuration. It creates a Chaos object that simulates pod failures for a specified duration, allowing users to test the resilience of their applications under failure conditions.
func (*NamespaceScopedChaosRunner) RunPodLoss ¶
func (cr *NamespaceScopedChaosRunner) RunPodLoss(ctx context.Context, cfg PodLossCfg) (*Chaos, error)
RunPodLoss initiates packet loss for some pod in some namespace
func (*NamespaceScopedChaosRunner) RunPodPartition ¶
func (cr *NamespaceScopedChaosRunner) RunPodPartition(ctx context.Context, cfg PodPartitionCfg) (*Chaos, error)
RunPodPartition initiates a network partition chaos experiment on specified pods. It configures the experiment based on the provided PodPartitionCfg and executes it. This function is useful for testing the resilience of applications under network partition scenarios.
func (*NamespaceScopedChaosRunner) RunPodStressCPU ¶
func (cr *NamespaceScopedChaosRunner) RunPodStressCPU(ctx context.Context, cfg NodeCPUStressConfig) (*Chaos, error)
RunPodStressCPU initiates a CPU stress test on specified pods within a namespace. It creates a scheduled chaos experiment that applies CPU load based on the provided configuration. This function is useful for testing the resilience of applications under CPU stress conditions.
type NetworkChaosOpts ¶
type NetworkChaosOpts struct {
Name string
Description string
DelayCreate time.Duration
Delay *v1alpha1.DelaySpec
Loss *v1alpha1.LossSpec
NodeCount int
Duration time.Duration
Selector v1alpha1.PodSelectorSpec
K8sClient client.Client
}
func (*NetworkChaosOpts) Validate ¶
func (o *NetworkChaosOpts) Validate() error
type NodeCPUStressConfig ¶
type PodChaosOpts ¶
type PodCorruptCfg ¶
type PodDelayCfg ¶
type PodFailCfg ¶
type PodLossCfg ¶
type PodPartitionCfg ¶
type RangeGrafanaAnnotator ¶
type RangeGrafanaAnnotator struct {
// contains filtered or unexported fields
}
func NewRangeGrafanaAnnotator ¶
func NewRangeGrafanaAnnotator(grafanaURL, grafanaToken, dashboardUID string, logger zerolog.Logger) *RangeGrafanaAnnotator
func (RangeGrafanaAnnotator) OnChaosCreated ¶
func (l RangeGrafanaAnnotator) OnChaosCreated(chaos Chaos)
func (RangeGrafanaAnnotator) OnChaosCreationFailed ¶
func (l RangeGrafanaAnnotator) OnChaosCreationFailed(chaos Chaos, reason error)
func (RangeGrafanaAnnotator) OnChaosEnded ¶
func (l RangeGrafanaAnnotator) OnChaosEnded(chaos Chaos)
func (RangeGrafanaAnnotator) OnChaosPaused ¶
func (l RangeGrafanaAnnotator) OnChaosPaused(chaos Chaos)
func (RangeGrafanaAnnotator) OnChaosStarted ¶
func (l RangeGrafanaAnnotator) OnChaosStarted(chaos Chaos)
func (RangeGrafanaAnnotator) OnChaosStatusUnknown ¶
func (l RangeGrafanaAnnotator) OnChaosStatusUnknown(chaos Chaos)
OnChaosStatusUnknown handles the event when the status of a chaos experiment is unknown. It allows listeners to respond appropriately to this specific status change in the chaos lifecycle.
type SimplifiedEvent ¶
type SingleLineGrafanaAnnotator ¶
type SingleLineGrafanaAnnotator struct {
// contains filtered or unexported fields
}
SingleLineGrafanaAnnotator annotates Grafana dashboards with chaos experiment events in a single line.
func NewSingleLineGrafanaAnnotator ¶
func NewSingleLineGrafanaAnnotator(grafanaURL, grafanaToken, dashboardUID string, logger zerolog.Logger) *SingleLineGrafanaAnnotator
func (SingleLineGrafanaAnnotator) OnChaosCreated ¶
func (l SingleLineGrafanaAnnotator) OnChaosCreated(chaos Chaos)
func (SingleLineGrafanaAnnotator) OnChaosCreationFailed ¶
func (l SingleLineGrafanaAnnotator) OnChaosCreationFailed(chaos Chaos, reason error)
func (SingleLineGrafanaAnnotator) OnChaosEnded ¶
func (l SingleLineGrafanaAnnotator) OnChaosEnded(chaos Chaos)
func (SingleLineGrafanaAnnotator) OnChaosPaused ¶
func (l SingleLineGrafanaAnnotator) OnChaosPaused(chaos Chaos)
func (SingleLineGrafanaAnnotator) OnChaosStarted ¶
func (l SingleLineGrafanaAnnotator) OnChaosStarted(chaos Chaos)
func (SingleLineGrafanaAnnotator) OnChaosStatusUnknown ¶
func (l SingleLineGrafanaAnnotator) OnChaosStatusUnknown(chaos Chaos)
OnChaosStatusUnknown handles the event when the status of a chaos experiment is unknown. It allows listeners to respond appropriately to this specific status change in the chaos lifecycle.