Documentation
¶
Index ¶
- type DNSChaosInfo
- type Event
- type EventStore
- type Experiment
- func (e *Experiment) ParseDNSChaos() (ExperimentYAMLDescription, error)
- func (e *Experiment) ParseIOChaos() (ExperimentYAMLDescription, error)
- func (e *Experiment) ParseKernelChaos() (ExperimentYAMLDescription, error)
- func (e *Experiment) ParseNetworkChaos() (ExperimentYAMLDescription, error)
- func (e *Experiment) ParsePodChaos() (ExperimentYAMLDescription, error)
- func (e *Experiment) ParseStressChaos() (ExperimentYAMLDescription, error)
- func (e *Experiment) ParseTimeChaos() (ExperimentYAMLDescription, error)
- type ExperimentInfo
- type ExperimentMeta
- type ExperimentStore
- type ExperimentYAMLDescription
- type ExperimentYAMLMetadata
- type Filter
- type IOChaosInfo
- type KernelChaosInfo
- type NetworkChaosInfo
- type PodChaosInfo
- type PodRecord
- type SchedulerInfo
- type ScopeInfo
- type SelectorInfo
- type StressChaosInfo
- type TargetInfo
- type TimeChaosInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DNSChaosInfo ¶ added in v1.1.0
type DNSChaosInfo struct { Action string `json:"action" binding:"oneof='error' 'random'"` Scope string `json:"scope" binding:"oneof='outer' 'inner' 'all'"` }
DNSChaosInfo defines the basic information of dns chaos for creating a new DNSChaos.
type Event ¶
type Event struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `sql:"index" json:"deleted_at"` Experiment string `gorm:"index:experiment" json:"experiment"` Namespace string `json:"namespace"` Kind string `json:"kind"` Message string `json:"message"` StartTime *time.Time `gorm:"index:start_time" json:"start_time"` FinishTime *time.Time `json:"finish_time"` Duration string `json:"duration"` Pods []*PodRecord `gorm:"-" json:"pods"` ExperimentID string `gorm:"index:experiment_id" json:"experiment_id"` }
Event represents an event instance.
type EventStore ¶
type EventStore interface { // List returns an event list from the datastore. List(context.Context) ([]*Event, error) // ListByFilter returns an event list by podName, podNamespace, experimentName, experimentNamespace, uid, kind, startTime and finishTime. ListByFilter(context.Context, Filter) ([]*Event, error) // ListByExperiment returns an event list by the name and namespace of the experiment. ListByExperiment(context.Context, string, string) ([]*Event, error) // ListByNamespace returns an event list by the namespace of the pod. ListByNamespace(context.Context, string) ([]*Event, error) // ListByPod returns an event list by the name and namespace of the pod. ListByPod(context.Context, string, string) ([]*Event, error) // ListByUID returns an event list by the UID. ListByUID(context.Context, string) ([]*Event, error) // DryListByFilter returns an event list by experimentName, experimentNamespace, uid, kind, startTime and finishTime. DryListByFilter(context.Context, Filter) ([]*Event, error) // Find returns an event from the datastore by ID. Find(context.Context, uint) (*Event, error) // FindByExperimentAndStartTime returns an event by the experiment and start time. FindByExperimentAndStartTime(context.Context, string, string, *time.Time) (*Event, error) // Create persists a new event to the datastore. Create(context.Context, *Event) error // Update persists an updated event to the datastore. Update(context.Context, *Event) error // DeleteIncompleteEvent deletes all incomplete events. // If the chaos-dashboard was restarted, some incomplete events would be stored in datastore, // which means the event would never save the finish_time. // DeleteIncompleteEvent can be used to delete all incomplete events to avoid this case. DeleteIncompleteEvents(context.Context) error // DeleteByFinishTime deletes events and podrecords whose time difference is greater than the given time from FinishTime. DeleteByFinishTime(context.Context, time.Duration) error // DeleteByUID deletes events list by the UID. DeleteByUID(context.Context, string) error // UpdateIncompleteEvents updates the incomplete event by the namespace and name // If chaos is deleted before an event is over, then the incomplete event would be stored in datastore, // which means the event would never save the finish_time. // UpdateIncompleteEvents can update the finish_time when the chaos is deleted. UpdateIncompleteEvents(context.Context, string, string) error }
EventStore defines operations for working with event.
type Experiment ¶ added in v1.1.0
type Experiment struct { ExperimentMeta Experiment string `gorm:"size:2048"` // JSON string }
Experiment represents an experiment instance. Use in db.
func (*Experiment) ParseDNSChaos ¶ added in v1.1.0
func (e *Experiment) ParseDNSChaos() (ExperimentYAMLDescription, error)
ParseDNSChaos Parse DNSChaos JSON string into ExperimentYAMLDescription.
func (*Experiment) ParseIOChaos ¶ added in v1.1.0
func (e *Experiment) ParseIOChaos() (ExperimentYAMLDescription, error)
ParseIOChaos Parse IOChaos JSON string into ExperimentYAMLDescription.
func (*Experiment) ParseKernelChaos ¶ added in v1.1.0
func (e *Experiment) ParseKernelChaos() (ExperimentYAMLDescription, error)
ParseKernelChaos Parse KernelChaos JSON string into ExperimentYAMLDescription.
func (*Experiment) ParseNetworkChaos ¶ added in v1.1.0
func (e *Experiment) ParseNetworkChaos() (ExperimentYAMLDescription, error)
ParseNetworkChaos Parse NetworkChaos JSON string into ExperimentYAMLDescription.
func (*Experiment) ParsePodChaos ¶ added in v1.1.0
func (e *Experiment) ParsePodChaos() (ExperimentYAMLDescription, error)
ParsePodChaos Parse PodChaos JSON string into ExperimentYAMLDescription.
func (*Experiment) ParseStressChaos ¶ added in v1.1.0
func (e *Experiment) ParseStressChaos() (ExperimentYAMLDescription, error)
ParseStressChaos Parse StressChaos JSON string into ExperimentYAMLDescription.
func (*Experiment) ParseTimeChaos ¶ added in v1.1.0
func (e *Experiment) ParseTimeChaos() (ExperimentYAMLDescription, error)
ParseTimeChaos Parse TimeChaos JSON string into ExperimentYAMLDescription.
type ExperimentInfo ¶
type ExperimentInfo struct { Name string `json:"name" binding:"required,NameValid"` Namespace string `json:"namespace" binding:"required,NameValid"` Labels map[string]string `json:"labels" binding:"MapSelectorsValid"` Annotations map[string]string `json:"annotations" binding:"MapSelectorsValid"` Scope ScopeInfo `json:"scope"` Target TargetInfo `json:"target"` Scheduler SchedulerInfo `json:"scheduler"` }
ExperimentInfo defines a form data of Experiment from API.
type ExperimentMeta ¶ added in v1.1.0
type ExperimentMeta struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `sql:"index" json:"deleted_at"` UID string `gorm:"index:uid" json:"uid"` Kind string `json:"kind"` Name string `json:"name"` Namespace string `json:"namespace"` Action string `json:"action"` StartTime time.Time `json:"start_time"` FinishTime time.Time `json:"finish_time"` Archived bool `json:"archived"` }
ExperimentMeta defines the metadata of an experiment. Use in db.
type ExperimentStore ¶
type ExperimentStore interface { // ListMeta returns experiment metadata list from the datastore. ListMeta(ctx context.Context, kind, namespace, name string, archived bool) ([]*ExperimentMeta, error) // FindByUID returns an experiment by UID. FindByUID(ctx context.Context, UID string) (*Experiment, error) // FindMetaByUID returns an experiment metadata by UID. FindMetaByUID(context.Context, string) (*ExperimentMeta, error) // Set saves the experiment to datastore. Set(context.Context, *Experiment) error // Archive archives experiments which "archived" field is false. Archive(ctx context.Context, namespace, name string) error // Delete deletes the archive from the datastore. Delete(context.Context, *Experiment) error // DeleteByFinishTime deletes archives which time difference is greater than the given time from FinishTime. DeleteByFinishTime(context.Context, time.Duration) error // DeleteIncompleteExperiments deletes all incomplete experiments. // If the chaos-dashboard was restarted and the experiment is completed during the restart, // which means the experiment would never save the finish_time. // DeleteIncompleteExperiments can be used to delete all incomplete experiments to avoid this case. DeleteIncompleteExperiments(context.Context) error }
ExperimentStore defines operations for working with experiments.
type ExperimentYAMLDescription ¶ added in v1.1.0
type ExperimentYAMLDescription struct { APIVersion string `json:"apiVersion"` Kind string `json:"kind"` Metadata ExperimentYAMLMetadata `json:"metadata"` Spec interface{} `json:"spec"` }
ExperimentYAMLDescription defines the YAML structure of an experiment.
type ExperimentYAMLMetadata ¶ added in v1.1.0
type ExperimentYAMLMetadata struct { Name string `json:"name"` Namespace string `json:"namespace"` Labels map[string]string `json:"labels"` Annotations map[string]string `json:"annotations"` }
ExperimentYAMLMetadata defines the metadata of YAMLDescription.
type Filter ¶
type Filter struct { PodName string PodNamespace string StartTimeStr string FinishTimeStr string ExperimentName string ExperimentNamespace string UID string Kind string LimitStr string }
Filter represents the filter to list events
type IOChaosInfo ¶
type IOChaosInfo struct { Action string `json:"action" binding:"oneof='' 'latency' 'fault' 'attrOverride'"` Delay string `json:"delay"` Errno uint32 `json:"errno"` Attr *v1alpha1.AttrOverrideSpec `json:"attr"` Path string `json:"path"` Percent int `json:"percent"` Methods []v1alpha1.IoMethod `json:"methods"` VolumePath string `json:"volume_path"` ContainerName string `json:"container_name"` }
IOChaosInfo defines the basic information of io chaos for creating a new IOChaos.
type KernelChaosInfo ¶
type KernelChaosInfo struct {
FailKernRequest v1alpha1.FailKernRequest `json:"fail_kern_request"`
}
KernelChaosInfo defines the basic information of kernel chaos for creating a new KernelChaos.
type NetworkChaosInfo ¶
type NetworkChaosInfo struct { Action string `json:"action" binding:"oneof='' 'netem' 'delay' 'loss' 'duplicate' 'corrupt' 'partition' 'bandwidth'"` Delay *v1alpha1.DelaySpec `json:"delay" binding:"RequiredFieldEqual=Action:delay"` Loss *v1alpha1.LossSpec `json:"loss" binding:"RequiredFieldEqual=Action:loss"` Duplicate *v1alpha1.DuplicateSpec `json:"duplicate" binding:"RequiredFieldEqual=Action:duplicate"` Corrupt *v1alpha1.CorruptSpec `json:"corrupt" binding:"RequiredFieldEqual=Action:corrupt"` Bandwidth *v1alpha1.BandwidthSpec `json:"bandwidth" binding:"RequiredFieldEqual=Action:bandwidth"` Direction string `json:"direction" binding:"oneof='' 'to' 'from' 'both'"` TargetScope *ScopeInfo `json:"target_scope"` ExternalTargets []string `json:"external_targets"` }
NetworkChaosInfo defines the basic information of network chaos for creating a new NetworkChaos.
type PodChaosInfo ¶
type PodChaosInfo struct { Action string `json:"action" binding:"oneof='' 'pod-kill' 'pod-failure' 'container-kill'"` ContainerName string `json:"container_name"` GracePeriod int64 `json:"grace_period"` }
PodChaosInfo defines the basic information of pod chaos for creating a new PodChaos.
type PodRecord ¶
type PodRecord struct { ID uint `gorm:"primary_key" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *time.Time `sql:"index" json:"deleted_at"` EventID uint `gorm:"index:event_id" json:"event_id"` PodIP string `gorm:"index:pod_id" json:"pod_ip"` PodName string `json:"pod_name"` Namespace string `json:"namespace"` Message string `json:"message"` Action string `json:"action"` }
PodRecord represents a pod record with event ID.
type SchedulerInfo ¶
type SchedulerInfo struct { Cron string `json:"cron" binding:"CronValid"` Duration string `json:"duration" binding:"DurationValid"` }
SchedulerInfo defines the scheduler information.
type ScopeInfo ¶
type ScopeInfo struct { SelectorInfo Mode string `json:"mode" binding:"oneof='' 'one' 'all' 'fixed' 'fixed-percent' 'random-max-percent'"` Value string `json:"value" binding:"ValueValid"` }
ScopeInfo defines the scope of the Experiment.
type SelectorInfo ¶
type SelectorInfo struct { NamespaceSelectors []string `json:"namespace_selectors" binding:"NamespaceSelectorsValid"` LabelSelectors map[string]string `json:"label_selectors" binding:"MapSelectorsValid"` ExpressionSelectors []metav1.LabelSelectorRequirement `json:"expression_selectors" binding:"RequirementSelectorsValid"` AnnotationSelectors map[string]string `json:"annotation_selectors" binding:"MapSelectorsValid"` FieldSelectors map[string]string `json:"field_selectors" binding:"MapSelectorsValid"` PhaseSelector []string `json:"phase_selectors" binding:"PhaseSelectorsValid"` // Pods is a map of string keys and a set values that used to select pods. // The key defines the namespace which pods belong, // and the each values is a set of pod names. Pods map[string][]string `json:"pods" binding:"PodsValid"` }
SelectorInfo defines the selector options of the Experiment.
func (*SelectorInfo) ParseSelector ¶
func (s *SelectorInfo) ParseSelector() v1alpha1.SelectorSpec
ParseSelector parses SelectorInfo to v1alpha1.SelectorSpec
type StressChaosInfo ¶
type StressChaosInfo struct { Stressors *v1alpha1.Stressors `json:"stressors"` StressngStressors string `json:"stressng_stressors,omitempty"` ContainerName *string `json:"container_name,omitempty"` }
StressChaosInfo defines the basic information of stress chaos for creating a new StressChaos.
type TargetInfo ¶
type TargetInfo struct { Kind string `json:"kind" binding:"required,oneof=PodChaos NetworkChaos IoChaos KernelChaos TimeChaos StressChaos DNSChaos"` PodChaos *PodChaosInfo `json:"pod_chaos,omitempty" binding:"RequiredFieldEqual=Kind:PodChaos"` NetworkChaos *NetworkChaosInfo `json:"network_chaos,omitempty" binding:"RequiredFieldEqual=Kind:NetworkChaos"` IOChaos *IOChaosInfo `json:"io_chaos,omitempty" binding:"RequiredFieldEqual=Kind:IoChaos"` KernelChaos *KernelChaosInfo `json:"kernel_chaos,omitempty" binding:"RequiredFieldEqual=Kind:KernelChaos"` TimeChaos *TimeChaosInfo `json:"time_chaos,omitempty" binding:"RequiredFieldEqual=Kind:TimeChaos"` StressChaos *StressChaosInfo `json:"stress_chaos,omitempty" binding:"RequiredFieldEqual=Kind:StressChaos"` DNSChaos *DNSChaosInfo `json:"dns_chaos,omitempty" binding:"RequiredFieldEqual=Kind:DNSChaos"` }
TargetInfo defines the information of target objects.
type TimeChaosInfo ¶
type TimeChaosInfo struct { TimeOffset string `json:"time_offset"` ClockIDs []string `json:"clock_ids"` ContainerNames []string `json:"container_names"` }
TimeChaosInfo defines the basic information of time chaos for creating a new TimeChaos.