Documentation
¶
Index ¶
- Constants
- Variables
- func CheckFlags(flags map[string]string) error
- func CheckPodFlags(flags map[string]string) error
- func CreateDestroyedStatus(oldExpStatus v1alpha1.ExperimentStatus) v1alpha1.ExperimentStatus
- func ExcludeKeyFunc() func() map[string]spec.Empty
- func ExtractExpModelFromExperimentSpec(experimentSpec v1alpha1.ExperimentSpec) *spec.ExpModel
- func GetChaosBladeFlags() []spec.ExpFlagSpec
- func GetContainerFlags() []spec.ExpFlagSpec
- func GetExperimentIdFromContext(ctx context.Context) string
- func GetOneAvailableContainerIdFromPod(pod v1.Pod) (containerId, containerName string, err error)
- func GetResourceCommonFlags() []spec.ExpFlagSpec
- func GetResourceCount(resourceCount int, flags map[string]string) (int, error)
- func GetResourceCoverageFlags() []spec.ExpFlagSpec
- func GetResourceFlagNames() map[string]spec.Empty
- func MapContains(bigMap map[string]string, subMap map[string]string) bool
- func ParseLabels(labels string) map[string]string
- func SetContainerObjectMetaListToContext(ctx context.Context, containerMatchedList ContainerMatchedList) context.Context
- func SetExperimentIdToContext(ctx context.Context, experimentId string) context.Context
- func TruncateContainerObjectMetaUid(uid string) string
- type BaseExperimentController
- func (b *BaseExperimentController) Destroy(ctx context.Context, expSpec v1alpha1.ExperimentSpec) *spec.Response
- func (b *BaseExperimentController) Exec(ctx context.Context, expModel *spec.ExpModel) *spec.Response
- func (b *BaseExperimentController) GetMatchedPodResources(ctx context.Context, expModel spec.ExpModel) ([]v1.Pod, error)
- type BaseResourceExpModelSpec
- func (b *BaseResourceExpModelSpec) ExpModels() map[string]spec.ExpModelCommandSpec
- func (b *BaseResourceExpModelSpec) GetExpActionModelSpec(target, actionName string) spec.ExpActionCommandSpec
- func (b *BaseResourceExpModelSpec) RegisterExpModels(expModel ...spec.ExpModelCommandSpec)
- func (b *BaseResourceExpModelSpec) Scope() string
- type BaseSubResourceExpModelSpec
- type ContainerMatchedList
- type ContainerObjectMeta
- type CopyOptions
- type ExecCommandInPodExecutor
- func (e *ExecCommandInPodExecutor) Exec(uid string, ctx context.Context, expModel *spec.ExpModel) *spec.Response
- func (e *ExecCommandInPodExecutor) GetChaosBladeDaemonsetPodName(nodeName string) (string, error)
- func (e *ExecCommandInPodExecutor) Name() string
- func (e *ExecCommandInPodExecutor) SetChannel(channel spec.Channel)
- type ExpController
- type ExperimentController
- type ExperimentIdentifierInPod
- type OSSubResourceModelSpec
- type ResourceExpModelSpec
- type SubResourceExpModelSpec
Constants ¶
const CategorySystemContainer = "system_container"
const ContainerObjectMetaListKey = "ContainerObjectMetaListKey"
const DefaultNamespace = "default"
const ExperimentIdKey = "ExperimentIdKey"
Variables ¶
var ChaosBladeDeployedPathFlag = &spec.ExpFlag{
Name: "chaosblade-deployed-path",
Desc: "Chaosblade tool deployed path, default value is /opt",
}
var ContainerIdsFlag = &spec.ExpFlag{ Name: "container-ids", Desc: "Container ids", NoArgs: false, Required: false, }
var ContainerIndexFlag = &spec.ExpFlag{
Name: "container-index",
Desc: "Container index, start from 0",
}
var ContainerNamesFlag = &spec.ExpFlag{ Name: "container-names", Desc: "Container names", NoArgs: false, Required: false, }
var ResourceCountFlag = &spec.ExpFlag{ Name: "evict-count", Desc: "Count of affected resource", NoArgs: false, Required: false, }
var ResourceGroupKeyFlag = &spec.ExpFlag{ Name: "evict-group", Desc: "Group key from labels", NoArgs: false, Required: false, }
var ResourceLabelsFlag = &spec.ExpFlag{ Name: "labels", Desc: "Label selector, the relationship between values that are or", NoArgs: false, Required: false, }
var ResourceNamesFlag = &spec.ExpFlag{ Name: "names", Desc: "Resource names, such as pod name. You must add namespace flag for it. Multiple parameters are separated directly by commas", NoArgs: false, Required: false, }
var ResourceNamespaceFlag = &spec.ExpFlag{ Name: "namespace", Desc: "Namespace, such as default, only one value can be specified", NoArgs: false, Required: true, }
var ResourcePercentFlag = &spec.ExpFlag{ Name: "evict-percent", Desc: "Percent of affected resource, integer value without %", NoArgs: false, Required: false, }
Functions ¶
func CheckFlags ¶
func CheckPodFlags ¶
func CreateDestroyedStatus ¶
func CreateDestroyedStatus(oldExpStatus v1alpha1.ExperimentStatus) v1alpha1.ExperimentStatus
CreateDestroyedStatus returns the ExperimentStatus with destroyed state
func ExcludeKeyFunc ¶
func ExtractExpModelFromExperimentSpec ¶
func ExtractExpModelFromExperimentSpec(experimentSpec v1alpha1.ExperimentSpec) *spec.ExpModel
ExtractExpModelFromExperimentSpec convert ExperimentSpec to ExpModel
func GetChaosBladeFlags ¶ added in v0.7.0
func GetChaosBladeFlags() []spec.ExpFlagSpec
func GetContainerFlags ¶
func GetContainerFlags() []spec.ExpFlagSpec
func GetExperimentIdFromContext ¶ added in v0.7.0
GetExperimentIdFromContext
func GetResourceCommonFlags ¶
func GetResourceCommonFlags() []spec.ExpFlagSpec
func GetResourceCount ¶
func GetResourceCoverageFlags ¶
func GetResourceCoverageFlags() []spec.ExpFlagSpec
func GetResourceFlagNames ¶
func MapContains ¶ added in v0.8.0
func ParseLabels ¶ added in v0.8.0
func SetContainerObjectMetaListToContext ¶ added in v0.7.0
func SetContainerObjectMetaListToContext(ctx context.Context, containerMatchedList ContainerMatchedList) context.Context
SetContainerObjectMetaListToContext
func SetExperimentIdToContext ¶ added in v0.7.0
SetExperimentIdToContext
Types ¶
type BaseExperimentController ¶
type BaseExperimentController struct { Client *channel.Client ResourceModelSpec ResourceExpModelSpec }
func (*BaseExperimentController) Destroy ¶
func (b *BaseExperimentController) Destroy(ctx context.Context, expSpec v1alpha1.ExperimentSpec) *spec.Response
func (*BaseExperimentController) Exec ¶
func (b *BaseExperimentController) Exec(ctx context.Context, expModel *spec.ExpModel) *spec.Response
Exec gets action executor and execute experiments
func (*BaseExperimentController) GetMatchedPodResources ¶
func (b *BaseExperimentController) GetMatchedPodResources(ctx context.Context, expModel spec.ExpModel) ([]v1.Pod, error)
GetMatchedPodResources return matched pods
type BaseResourceExpModelSpec ¶
type BaseResourceExpModelSpec struct { ScopeName string Client *channel.Client ExpModelSpecs map[string]spec.ExpModelCommandSpec }
func NewBaseResourceExpModelSpec ¶
func NewBaseResourceExpModelSpec(scopeName string, client *channel.Client) BaseResourceExpModelSpec
func (*BaseResourceExpModelSpec) ExpModels ¶
func (b *BaseResourceExpModelSpec) ExpModels() map[string]spec.ExpModelCommandSpec
func (*BaseResourceExpModelSpec) GetExpActionModelSpec ¶
func (b *BaseResourceExpModelSpec) GetExpActionModelSpec(target, actionName string) spec.ExpActionCommandSpec
func (*BaseResourceExpModelSpec) RegisterExpModels ¶
func (b *BaseResourceExpModelSpec) RegisterExpModels(expModel ...spec.ExpModelCommandSpec)
func (*BaseResourceExpModelSpec) Scope ¶
func (b *BaseResourceExpModelSpec) Scope() string
type BaseSubResourceExpModelSpec ¶
type BaseSubResourceExpModelSpec struct { ExpModelSpecs []spec.ExpModelCommandSpec ExpExecutor spec.Executor }
func (*BaseSubResourceExpModelSpec) Executor ¶
func (b *BaseSubResourceExpModelSpec) Executor() spec.Executor
func (*BaseSubResourceExpModelSpec) ExpModels ¶
func (b *BaseSubResourceExpModelSpec) ExpModels() []spec.ExpModelCommandSpec
type ContainerMatchedList ¶ added in v0.7.0
type ContainerMatchedList []ContainerObjectMeta
func GetContainerObjectMetaListFromContext ¶ added in v0.7.0
func GetContainerObjectMetaListFromContext(ctx context.Context) (ContainerMatchedList, error)
GetContainerObjectMetaListFromContext returns the matched container list
type ContainerObjectMeta ¶
type ContainerObjectMeta struct { // experiment id Id string ContainerId string ContainerName string PodName string NodeName string Namespace string }
func ParseIdentifier ¶ added in v0.7.0
func ParseIdentifier(identifier string) ContainerObjectMeta
Namespace/Node/Pod/ContainerName/ContainerId(12 length)
func (*ContainerObjectMeta) GetIdentifier ¶ added in v0.7.0
func (c *ContainerObjectMeta) GetIdentifier() string
type CopyOptions ¶ added in v0.7.0
type CopyOptions struct { Container string Namespace string PodName string // contains filtered or unexported fields }
func (*CopyOptions) CheckFileExists ¶ added in v0.7.0
func (o *CopyOptions) CheckFileExists(dest string) error
CheckFileExists return nil if dest file exists
func (*CopyOptions) CopyToPod ¶ added in v0.7.0
func (o *CopyOptions) CopyToPod(src, dest string) error
CopyToPod copies src file or directory to specify container
func (*CopyOptions) CreateDir ¶ added in v0.7.0
func (o *CopyOptions) CreateDir(dir string) error
type ExecCommandInPodExecutor ¶
func (*ExecCommandInPodExecutor) GetChaosBladeDaemonsetPodName ¶ added in v0.7.0
func (e *ExecCommandInPodExecutor) GetChaosBladeDaemonsetPodName(nodeName string) (string, error)
GetChaosBladeDaemonsetPodName
func (*ExecCommandInPodExecutor) Name ¶
func (e *ExecCommandInPodExecutor) Name() string
func (*ExecCommandInPodExecutor) SetChannel ¶
func (e *ExecCommandInPodExecutor) SetChannel(channel spec.Channel)
type ExpController ¶
type ExpController interface { // controller Name Name() string // Create Create(bladeName string, expSpec v1alpha1.ExperimentSpec) v1alpha1.ExperimentStatus // Destroy Destroy(bladeName string, expSpec v1alpha1.ExperimentSpec, oldExpStatus v1alpha1.ExperimentStatus) v1alpha1.ExperimentStatus }
type ExperimentController ¶
type ExperimentController interface { // controller Name Name() string // Create experiment Create(ctx context.Context, expSpec v1alpha1.ExperimentSpec) *spec.Response // Destroy Destroy(ctx context.Context, expSpec v1alpha1.ExperimentSpec, oldExpStatus v1alpha1.ExperimentStatus) *spec.Response }
type ExperimentIdentifierInPod ¶ added in v0.7.0
type OSSubResourceModelSpec ¶ added in v0.7.0
type OSSubResourceModelSpec struct {
BaseSubResourceExpModelSpec
}
type ResourceExpModelSpec ¶
type ResourceExpModelSpec interface { Scope() string ExpModels() map[string]spec.ExpModelCommandSpec GetExpActionModelSpec(target, action string) spec.ExpActionCommandSpec }
ResourceExpModelSpec contains node, pod, container
type SubResourceExpModelSpec ¶
type SubResourceExpModelSpec interface { ExpModels() []spec.ExpModelCommandSpec Executor() spec.Executor }
SubResourceExpModelSpec contains os exps in node, network exp in pod and os exps in container
func NewOSSubResourceModelSpec ¶ added in v0.7.0
func NewOSSubResourceModelSpec() SubResourceExpModelSpec