model

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerObjectMetaListKey = "ContainerObjectMetaListKey"
View Source
const DefaultNamespace = "default"
View Source
const ExperimentIdKey = "ExperimentIdKey"

Variables

View Source
var ChaosBladeDeployedPathFlag = &spec.ExpFlag{
	Name: "chaosblade-deployed-path",
	Desc: "Chaosblade tool deployed path, default value is /opt",
}
View Source
var ContainerIdsFlag = &spec.ExpFlag{
	Name:     "container-ids",
	Desc:     "Container ids",
	NoArgs:   false,
	Required: false,
}
View Source
var ContainerIndexFlag = &spec.ExpFlag{
	Name: "container-index",
	Desc: "Container index, start from 0",
}
View Source
var ContainerNamesFlag = &spec.ExpFlag{
	Name:     "container-names",
	Desc:     "Container names",
	NoArgs:   false,
	Required: false,
}
View Source
var ResourceCountFlag = &spec.ExpFlag{
	Name:     "evict-count",
	Desc:     "Count of affected resource",
	NoArgs:   false,
	Required: false,
}
View Source
var ResourceGroupKeyFlag = &spec.ExpFlag{
	Name:     "evict-group",
	Desc:     "Group key from labels",
	NoArgs:   false,
	Required: false,
}
View Source
var ResourceLabelsFlag = &spec.ExpFlag{
	Name:     "labels",
	Desc:     "Label selector, the relationship between values that are or",
	NoArgs:   false,
	Required: false,
}
View Source
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,
}
View Source
var ResourceNamespaceFlag = &spec.ExpFlag{
	Name:     "namespace",
	Desc:     "Namespace, such as default, only one value can be specified",
	NoArgs:   false,
	Required: true,
}
View Source
var ResourcePercentFlag = &spec.ExpFlag{
	Name:     "evict-percent",
	Desc:     "Percent of affected resource, integer value without %",
	NoArgs:   false,
	Required: false,
}

Functions

func CheckPodFlags

func CheckPodFlags(flags map[string]string) error

func CreateDestroyedStatus

func CreateDestroyedStatus(oldExpStatus v1alpha1.ExperimentStatus) v1alpha1.ExperimentStatus

CreateDestroyedStatus returns the ExperimentStatus with destroyed state

func ExcludeKeyFunc

func ExcludeKeyFunc() func() map[string]spec.Empty

func ExtractExpModelFromExperimentSpec

func ExtractExpModelFromExperimentSpec(experimentSpec v1alpha1.ExperimentSpec) *spec.ExpModel

ExtractExpModelFromExperimentSpec convert ExperimentSpec to ExpModel

func GetChaosBladeFlags

func GetChaosBladeFlags() []spec.ExpFlagSpec

func GetContainerFlags

func GetContainerFlags() []spec.ExpFlagSpec

func GetExperimentIdFromContext

func GetExperimentIdFromContext(ctx context.Context) string

GetExperimentIdFromContext

func GetOneAvailableContainerIdFromPod

func GetOneAvailableContainerIdFromPod(pod v1.Pod) (containerId, containerName string, err error)

func GetResourceCommonFlags

func GetResourceCommonFlags() []spec.ExpFlagSpec

func GetResourceCount

func GetResourceCount(resourceCount int, flags map[string]string) (int, error)

func GetResourceCoverageFlags

func GetResourceCoverageFlags() []spec.ExpFlagSpec

func GetResourceFlagNames

func GetResourceFlagNames() map[string]spec.Empty

func SetContainerObjectMetaListToContext

func SetContainerObjectMetaListToContext(ctx context.Context, containerMatchedList ContainerMatchedList) context.Context

SetContainerObjectMetaListToContext

func SetExperimentIdToContext

func SetExperimentIdToContext(ctx context.Context, experimentId string) context.Context

SetExperimentIdToContext

func TruncateContainerObjectMetaUid

func TruncateContainerObjectMetaUid(uid string) string

Types

type BaseExperimentController

type BaseExperimentController struct {
	Client            *channel.Client
	ResourceModelSpec ResourceExpModelSpec
}

func (*BaseExperimentController) Destroy

func (*BaseExperimentController) Exec

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 (*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 (*BaseSubResourceExpModelSpec) ExpModels

type ContainerMatchedList

type ContainerMatchedList []ContainerObjectMeta

func GetContainerObjectMetaListFromContext

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

func ParseIdentifier(identifier string) ContainerObjectMeta

Namespace/Node/Pod/ContainerName/ContainerId(12 length)

func (*ContainerObjectMeta) GetIdentifier

func (c *ContainerObjectMeta) GetIdentifier() string

type CopyOptions

type CopyOptions struct {
	Container string
	Namespace string
	PodName   string
	// contains filtered or unexported fields
}

func (*CopyOptions) CheckFileExists

func (o *CopyOptions) CheckFileExists(dest string) error

CheckFileExists return nil if dest file exists

func (*CopyOptions) CopyToPod

func (o *CopyOptions) CopyToPod(src, dest string) error

CopyToPod copies src file or directory to specify container

func (*CopyOptions) CreateDir

func (o *CopyOptions) CreateDir(dir string) error

type ExecCommandInPodExecutor

type ExecCommandInPodExecutor struct {
	Client *channel.Client
}

func (*ExecCommandInPodExecutor) Exec

func (e *ExecCommandInPodExecutor) Exec(uid string, ctx context.Context, expModel *spec.ExpModel) *spec.Response

func (*ExecCommandInPodExecutor) GetChaosBladeDaemonsetPodName

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

type ExperimentIdentifierInPod struct {
	ContainerObjectMeta
	Command string
	Error   string
	// For daemonset
	ChaosBladePodName       string
	ChaosBladeNamespace     string
	ChaosBladeContainerName string
}

type OSSubResourceModelSpec

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

func NewOSSubResourceModelSpec() SubResourceExpModelSpec

Jump to

Keyboard shortcuts

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