model

package
v1.8.6 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ChaosBladeDeployModeFlag = &spec.ExpFlag{
	Name: "chaosblade-deploy-mode",
	Desc: "The mode of chaosblade deployment in container, the values are copy and download, the default value is copy which copy tool from the operator to the target container. If you select download mode, the operator will download chaosblade tool from the chaosblade-download-url.",
}
View Source
var ChaosBladeDownloadUrlFlag = &spec.ExpFlag{
	Name: "chaosblade-download-url",
	Desc: "The chaosblade downloaded address. If you use download deployment mode, you must specify the value, or config chaosblade-download-url when deploying the operator",
}
View Source
var ChaosBladePathFlag = &spec.ExpFlag{
	Name: "chaosblade-path",
	Desc: "Chaosblade tool deployment path, default value is /opt. Please select a path with write permission",
}
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 CopyMode = "copy"
View Source
var DownloadMode = "download"
View Source
var IsDockerNetworkFlag = &spec.ExpFlag{
	Name:     "is-docker-network",
	Desc:     "Used when a docker container is used and there is no tc command in the target container. Just for docker command, Deprecated! Please use use-sidecar-container-network flag.",
	NoArgs:   true,
	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,
}
View Source
var UseSidecarContainerNetworkFlag = &spec.ExpFlag{
	Name:     "use-sidecar-container-network",
	Desc:     "When there is no tc command in the target container. Set the sidecar container network true.",
	NoArgs:   true,
	Required: false,
}

Functions

func CheckFlags

func CheckFlags(flags map[string]string) *spec.Response

func CheckPodFlags

func CheckPodFlags(flags map[string]string) *spec.Response

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 GetChaosBladeDaemonsetPodName

func GetChaosBladeDaemonsetPodName(nodeName string, client *channel.Client) (string, error)

GetChaosBladeDaemonsetPodName

func GetChaosBladeFlags

func GetChaosBladeFlags() []spec.ExpFlagSpec

func GetContainerFlags

func GetContainerFlags() []spec.ExpFlagSpec

func GetExperimentIdFromContext

func GetExperimentIdFromContext(ctx context.Context) string

GetExperimentIdFromContext

func GetNetworkFlags

func GetNetworkFlags() []spec.ExpFlagSpec

func GetOneAvailableContainerIdFromPod

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

func GetResourceCommonFlags

func GetResourceCommonFlags() []spec.ExpFlagSpec

func GetResourceCount

func GetResourceCount(resourceCount int, flags map[string]string) (int, *spec.Response)

func GetResourceCoverageFlags

func GetResourceCoverageFlags() []spec.ExpFlagSpec

func GetResourceFlagNames

func GetResourceFlagNames() map[string]spec.Empty

func MapContains

func MapContains(bigMap map[string]string, requirements []pkglabels.Requirement) bool

func ParallelizeExec

func ParallelizeExec(workCount int, doWork DoWorkFunc)

func ParseLabels

func ParseLabels(labels string) []pkglabels.Requirement

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) (containerRuntime, containerId 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, *spec.Response)

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 CommonExecutor

type CommonExecutor struct {
	Client *channel.Client
}

func (*CommonExecutor) Exec

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

func (*CommonExecutor) Name

func (e *CommonExecutor) Name() string

func (*CommonExecutor) SetChannel

func (e *CommonExecutor) SetChannel(channel spec.Channel)

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
	ContainerRuntime string
	ContainerId      string
	ContainerName    string
	PodName          string
	NodeName         string
	Namespace        string
}

func ParseIdentifier

func ParseIdentifier(identifier string) ContainerObjectMeta

Namespace/Node/Pod/ContainerName/ContainerId/containerRuntime

func (*ContainerObjectMeta) GetIdentifier

func (c *ContainerObjectMeta) GetIdentifier() string

type CopyOptions

type CopyOptions struct {
	DeployOptions
}

func (*CopyOptions) DeployToPod

func (o *CopyOptions) DeployToPod(experimentId, src, dest string) error

DeployToPod copies src file or directory to specify container

type DeployMode

type DeployMode interface {
	DeployToPod(experimentId, src, dest string) error
}

type DeployOptions

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

func (*DeployOptions) CheckFileExists

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

CheckFileExists return nil if dest file exists

func (*DeployOptions) CreateDir

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

type DoWorkFunc

type DoWorkFunc func(workID int)

type DownloadOptions

type DownloadOptions struct {
	DeployOptions
	// contains filtered or unexported fields
}

func (*DownloadOptions) DeployToPod

func (d *DownloadOptions) DeployToPod(experimentId, src, dest 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

execInMatchedPod will execute the experiment in the target pod

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
	Code    int32
	// 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