Documentation ¶
Index ¶
- Variables
- func ChaosObjectExists(object client.Object, c client.Client) (bool, error)
- func CreateLogger(config LoggerConfig) zerolog.Logger
- 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)
- func (l ChaosLogger) OnScheduleCreated(schedule Schedule)
- func (l ChaosLogger) OnScheduleDeleted(schedule Schedule)
- type ChaosOpts
- type ChaosStatus
- type LoggerConfig
- type NetworkChaosOpts
- type PodChaosOpts
- type RangeGrafanaAnnotator
- func (l RangeGrafanaAnnotator) OnChaosCreated(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosEnded(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosPaused(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosStarted(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnChaosStatusUnknown(chaos Chaos)
- func (l RangeGrafanaAnnotator) OnScheduleCreated(chaos Schedule)
- func (l RangeGrafanaAnnotator) OnScheduleDeleted(chaos Schedule)
- type Schedule
- func (s *Schedule) AddListener(listener ChaosListener)
- func (s *Schedule) Create(ctx context.Context)
- func (s *Schedule) Delete(ctx context.Context) error
- func (s *Schedule) GetChaosDescription() string
- func (s *Schedule) GetChaosDuration() (time.Duration, error)
- func (s *Schedule) GetChaosName() string
- func (s *Schedule) GetChaosSpec() interface{}
- func (s *Schedule) GetEndTime() time.Time
- func (s *Schedule) GetExpectedEndTime() (time.Time, error)
- func (s *Schedule) GetObject() client.Object
- func (s *Schedule) GetStartTime() time.Time
- type ScheduleOpts
- type ScheduleStatus
- 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)
- func (l SingleLineGrafanaAnnotator) OnScheduleCreated(s Schedule)
- func (l SingleLineGrafanaAnnotator) OnScheduleDeleted(s Schedule)
- type StressChaosOpts
Constants ¶
This section is empty.
Variables ¶
var Logger zerolog.Logger
Default logger
Functions ¶
func ChaosObjectExists ¶
func CreateLogger ¶
func CreateLogger(config LoggerConfig) zerolog.Logger
Create initializes a zerolog.Logger based on the specified configuration.
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 (*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) 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 OnScheduleCreated(chaos Schedule) OnScheduleDeleted(chaos Schedule) // When the chaos is finished or deleted }
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)
func (ChaosLogger) OnScheduleCreated ¶
func (l ChaosLogger) OnScheduleCreated(schedule Schedule)
func (ChaosLogger) OnScheduleDeleted ¶
func (l ChaosLogger) OnScheduleDeleted(schedule Schedule)
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 LoggerConfig ¶
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 PodChaosOpts ¶
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) 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)
func (RangeGrafanaAnnotator) OnScheduleCreated ¶
func (l RangeGrafanaAnnotator) OnScheduleCreated(chaos Schedule)
func (RangeGrafanaAnnotator) OnScheduleDeleted ¶
func (l RangeGrafanaAnnotator) OnScheduleDeleted(chaos Schedule)
type Schedule ¶
type Schedule struct { Object *v1alpha1.Schedule Description string DelayCreate time.Duration // Delay before creating the chaos object Duration time.Duration // Duration for which the chaos object should exist Status ChaosStatus Client client.Client // contains filtered or unexported fields }
func NewSchedule ¶
func NewSchedule(opts ScheduleOpts) (*Schedule, error)
func (*Schedule) AddListener ¶
func (s *Schedule) AddListener(listener ChaosListener)
func (*Schedule) 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 (*Schedule) GetChaosDescription ¶
func (*Schedule) GetChaosName ¶
func (*Schedule) GetChaosSpec ¶
func (s *Schedule) GetChaosSpec() interface{}
func (*Schedule) GetEndTime ¶
func (*Schedule) GetStartTime ¶
type ScheduleOpts ¶
type ScheduleStatus ¶
type ScheduleStatus string
const ( ScheduleStatusCreated ScheduleStatus = "created" ScheduleStatusDeleted ScheduleStatus = "deleted" ScheduleStatusUnknown ScheduleStatus = "unknown" // For any state that doesn't match the above )
type SimplifiedEvent ¶
type SingleLineGrafanaAnnotator ¶
type SingleLineGrafanaAnnotator struct {
// contains filtered or unexported fields
}
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)
func (SingleLineGrafanaAnnotator) OnScheduleCreated ¶
func (l SingleLineGrafanaAnnotator) OnScheduleCreated(s Schedule)
func (SingleLineGrafanaAnnotator) OnScheduleDeleted ¶
func (l SingleLineGrafanaAnnotator) OnScheduleDeleted(s Schedule)