common

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2021 License: Apache-2.0 Imports: 38 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ItemSuccess = iota + 1
	ItemFailure
)
View Source
const ChaosDaemonClientCert = "chaos-mesh-daemon-client-certs"
View Source
const ChaosDaemonNamespace = "chaos-testing"

Variables

View Source
var Insecure bool

Functions

func CheckFailedMessage

func CheckFailedMessage(ctx context.Context, failedMessage string, daemons []v1.Pod, c *ClientSet) error

CheckFailedMessage provide debug info and suggestions from failed message

func ConnectToLocalChaosDaemon added in v1.2.0

func ConnectToLocalChaosDaemon(port int) (daemonClient.ChaosDaemonClientInterface, error)

ConnectToLocalChaosDaemon would connect to ChaosDaemon run in localhost

func Exec

func Exec(ctx context.Context, pod v1.Pod, cmd string, c *kubernetes.Clientset) (string, error)

Exec executes certain command and returns the result Only commands in chaos-mesh components should use this way for target pod, use ExecBypass

func ExecBypass

func ExecBypass(ctx context.Context, pod v1.Pod, daemon v1.Pod, cmd string, c *kubernetes.Clientset) (string, error)

ExecBypass use chaos-daemon to enter namespace and execute command in target pod

func GetChaosList

func GetChaosList(ctx context.Context, chaosType string, chaosName string, ns string, c client.Client) ([]runtime.Object, []string, error)

GetChaosList returns chaos list limited by input

func GetPidFromPS

func GetPidFromPS(ctx context.Context, pod v1.Pod, daemon v1.Pod, c *kubernetes.Clientset) ([]string, []string, error)

GetPidFromPS returns pid-command pairs

func GetPidFromPod

func GetPidFromPod(ctx context.Context, pod v1.Pod, daemon v1.Pod) (uint32, error)

GetPidFromPod returns pid given containerd ID in pod

func GetPods

func GetPods(ctx context.Context, chaosName string, status v1alpha1.ChaosStatus, selectorSpec v1alpha1.SelectorSpec, c client.Client) ([]v1.Pod, []v1.Pod, error)

GetPods returns pod list and corresponding chaos daemon

func L added in v1.2.0

func L() logr.Logger

func Log

func Log(pod v1.Pod, tail int64, c *kubernetes.Clientset) (string, error)

Log print log of pod

func MarshalChaos

func MarshalChaos(s interface{}) (string, error)

MarshalChaos returns json in readable format

func PrettyPrint

func PrettyPrint(s string, indentLevel int, color Color)

PrettyPrint print with tab number and color

func PrintResult

func PrintResult(result []ChaosResult)

PrintResult prints result to users in prettier format

func SetupGlobalLogger added in v1.2.0

func SetupGlobalLogger(logger logr.Logger)

func SetupKlog added in v1.2.0

func SetupKlog() error

Types

type ChaosResult

type ChaosResult struct {
	Name string
	Pods []PodResult
}

type ClientSet

type ClientSet struct {
	CtrlCli client.Client
	KubeCli *kubernetes.Clientset
}

ClientSet contains two different clients

func InitClientSet

func InitClientSet() (*ClientSet, error)

InitClientSet inits two different clients that would be used

type Color added in v1.2.0

type Color string
const (
	Blue    Color = "Blue"
	Red     Color = "Red"
	Green   Color = "Green"
	Cyan    Color = "Cyan"
	NoColor Color = ""
)

type CommonRestClientGetter added in v1.2.0

type CommonRestClientGetter struct {
	*genericclioptions.ConfigFlags
}

CommonRestClientGetter is used for non-e2e test environment. It's basically do the same thing as genericclioptions.ConfigFlags, but it load rest config from incluster or .kubeconfig file

func NewCommonRestClientGetter added in v1.2.0

func NewCommonRestClientGetter() *CommonRestClientGetter

func (*CommonRestClientGetter) ToRESTConfig added in v1.2.0

func (it *CommonRestClientGetter) ToRESTConfig() (*rest.Config, error)

type ItemResult

type ItemResult struct {
	Name    string
	Value   string
	Status  int    `json:",omitempty"`
	SucInfo string `json:",omitempty"`
	ErrInfo string `json:",omitempty"`
}

type LoggerFlushFunc added in v1.2.0

type LoggerFlushFunc func()

func NewStderrLogger added in v1.2.0

func NewStderrLogger() (logr.Logger, LoggerFlushFunc, error)

type PodResult

type PodResult struct {
	Name  string
	Items []ItemResult
}

type TLSFileConfig added in v1.2.0

type TLSFileConfig struct {
	CaCert string
	Cert   string
	Key    string
}
var TLSFiles TLSFileConfig

Jump to

Keyboard shortcuts

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