Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPodMeetSelector(pod v1.Pod, selector v1alpha1.SelectorSpec) (bool, error)
- func Coalescer(interval time.Duration, input chan interface{}, stopCh <-chan struct{}) <-chan interface{}
- func CreateGrpcConnection(ctx context.Context, c client.Client, pod *v1.Pod, port int) (*grpc.ClientConn, error)
- func EncodeClkIds(clkIds []string) (uint64, error)
- func GenAnnotationKeyForImage(pc *v1alpha1.PodChaos, containerName string) string
- func GenAnnotationKeyForWebhook(prefix string, podName string) string
- func IgnoreNotFound(err error) error
- func InsertFinalizer(finalizers []string, finalizer string) []string
- func IsAllowedNamespaces(namespace string) bool
- func IsCaredNetError(err error) bool
- func MergeCommands(inject []string, origin []string, args []string) []string
- func MergeNetem(a, b *chaosdaemon.Netem) *chaosdaemon.Netem
- func NextTime(spec v1alpha1.SchedulerSpec, now time.Time, firstTime bool) (*time.Time, error)
- func RandomFixedIndexes(start, end, count uint) []uint
- func RemoveFromFinalizer(finalizers []string, key string) []string
- func SelectAndFilterPods(ctx context.Context, c client.Client, r client.Reader, spec SelectSpec) ([]v1.Pod, error)
- func SelectPods(ctx context.Context, c client.Client, r client.Reader, ...) ([]v1.Pod, error)
- func TimeoutClientInterceptor(ctx context.Context, method string, req, reply interface{}, ...) error
- func TimeoutServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- type ChaosDaemonClientInterface
- type Edge
- type Graph
- type GrpcChaosDaemonClient
- type SelectSpec
Constants ¶
const ( // The chaos just started EventChaosInjected string = "ChaosInjected" // The chaos just failed when injecting. The message should include detailed error EventChaosInjectFailed string = "ChaosInjectFailed" // The chaos just failed when recovering. The message should include detailed error EventChaosRecoverFailed string = "ChaosRecoverFailed" // The chaos just completed EventChaosRecovered string = "ChaosRecovered" )
For each chaos resource, the controller manager will record events once the chaos is started or completed or failed. The starting and completing events should be of type "Normal". And the failed events should be of type "Warning". The reasons are defined as following.
const (
// AnnotationPrefix defines the prefix of annotation key for chaos-mesh.
AnnotationPrefix = "chaos-mesh"
)
const DefaultRPCTimeout = 60 * time.Second
DefaultRPCTimeout specifies default timeout of RPC between controller and chaos-operator
Variables ¶
var RPCTimeout = DefaultRPCTimeout
RPCTimeout specifies timeout of RPC between controller and chaos-operator
Functions ¶
func CheckPodMeetSelector ¶
CheckPodMeetSelector checks if this pod meets the selection criteria. TODO: support to check fieldsSelector
func Coalescer ¶
func Coalescer(interval time.Duration, input chan interface{}, stopCh <-chan struct{}) <-chan interface{}
Coalescer takes an input channel, and coalesced inputs with a timebound of interval. If input channel is closed, coalescer will signal one last time if we have any pending unsignalled events and close the output channel.
func CreateGrpcConnection ¶
func CreateGrpcConnection(ctx context.Context, c client.Client, pod *v1.Pod, port int) (*grpc.ClientConn, error)
CreateGrpcConnection create a grpc connection with given port
func EncodeClkIds ¶
EncodeClkIds will convert array of clk ids into a mask
func IgnoreNotFound ¶
func InsertFinalizer ¶
func IsAllowedNamespaces ¶
IsAllowedNamespaces returns whether namespace allows the execution of a chaos task
func IsCaredNetError ¶
func MergeCommands ¶
MergeCommands merges injected commands and original commands for injecting commands to containers, eg: inject: []string{"bash", "-c", "/check.sh"}, origin: []string{"bash", "-c", "/run.sh"} merged commands: []string{"/bin/sh", "-ec", "/check.sh\n/run.sh"}
func MergeNetem ¶
func MergeNetem(a, b *chaosdaemon.Netem) *chaosdaemon.Netem
MergeNetem merges two Netem protos into a new one. REMEMBER to assign the return value, i.e. merged = utils.MergeNetm(merged, em) For each field it takes the bigger value of the two. Its main use case is merging netem of different types, e.g. delay and loss. It returns nil if both inputs are nil. Otherwise it returns a new Netem with merged values.
func RandomFixedIndexes ¶
RandomFixedIndexes returns the `count` random indexes between `start` and `end`. [start, end)
func RemoveFromFinalizer ¶
func SelectAndFilterPods ¶
func SelectAndFilterPods(ctx context.Context, c client.Client, r client.Reader, spec SelectSpec) ([]v1.Pod, error)
SelectAndFilterPods returns the list of pods that filtered by selector and PodMode
func SelectPods ¶
func SelectPods(ctx context.Context, c client.Client, r client.Reader, selector v1alpha1.SelectorSpec) ([]v1.Pod, error)
SelectPods returns the list of pods that are available for pod chaos action. It returns all pods that match the configured label, annotation and namespace selectors. If pods are specifically specified by `selector.Pods`, it just returns the selector.Pods.
func TimeoutClientInterceptor ¶
func TimeoutClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
TimeoutClientInterceptor wraps the RPC with a timeout.
func TimeoutServerInterceptor ¶
func TimeoutServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)
TimeoutServerInterceptor ensures the context is intact before handling over the request to application.
Types ¶
type ChaosDaemonClientInterface ¶
type ChaosDaemonClientInterface interface { chaosdaemon.ChaosDaemonClient Close() error }
ChaosDaemonClientInterface represents the ChaosDaemonClient, it's used to simply unit test
type Graph ¶
type Graph struct {
// contains filtered or unexported fields
}
Graph represents a graph with link list
func (*Graph) Flatten ¶
Flatten flattens the subtree from source (without checking whether it's a tree)
type GrpcChaosDaemonClient ¶
type GrpcChaosDaemonClient struct { chaosdaemon.ChaosDaemonClient // contains filtered or unexported fields }
GrpcChaosDaemonClient would act like chaosdaemon.ChaosDaemonClient with a Close method
func (*GrpcChaosDaemonClient) Close ¶
func (c *GrpcChaosDaemonClient) Close() error
type SelectSpec ¶
type SelectSpec interface { GetSelector() v1alpha1.SelectorSpec GetMode() v1alpha1.PodMode GetValue() string }