common

package
v0.0.0-...-3568c51 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbortWatcher

func AbortWatcher(expname string, clients clients.ClientSets, resultDetails *types.ResultDetails, chaosDetails *types.ChaosDetails, eventsDetails *types.EventDetails)

AbortWatcher continuously watch for the abort signals it will update chaosresult w/ failed step and create an abort event, if it received abort signal during chaos

func AbortWatcherWithoutExit

func AbortWatcherWithoutExit(expname string, clients clients.ClientSets, resultDetails *types.ResultDetails, chaosDetails *types.ChaosDetails, eventsDetails *types.EventDetails)

AbortWatcherWithoutExit continuously watch for the abort signals

func CheckContainerStatus

func CheckContainerStatus(appNamespace, appName string, clients clients.ClientSets) error

CheckContainerStatus checks the status of the application container

func CheckForAvailibiltyOfPod

func CheckForAvailibiltyOfPod(namespace, name string, clients clients.ClientSets) (bool, error)

CheckForAvailibiltyOfPod check the availibility of the specified pod

func DeleteAllHelperPodBasedOnJobCleanupPolicy

func DeleteAllHelperPodBasedOnJobCleanupPolicy(podLabel string, chaosDetails *types.ChaosDetails, clients clients.ClientSets)

DeleteAllHelperPodBasedOnJobCleanupPolicy delete all the helper pods w/ matching label based on jobCleanupPolicy

func DeleteAllPod

func DeleteAllPod(podLabel, namespace string, timeout, delay int, clients clients.ClientSets) error

DeleteAllPod deletes all the pods with matching labels and wait until all the pods got terminated

func DeleteHelperPodBasedOnJobCleanupPolicy

func DeleteHelperPodBasedOnJobCleanupPolicy(podName, podLabel string, chaosDetails *types.ChaosDetails, clients clients.ClientSets)

DeleteHelperPodBasedOnJobCleanupPolicy deletes specific helper pod based on jobCleanupPolicy

func DeletePod

func DeletePod(podName, podLabel, namespace string, timeout, delay int, clients clients.ClientSets) error

DeletePod deletes the specified pod and wait until it got terminated

func FilterBasedOnPercentage

func FilterBasedOnPercentage(percentage int, list []string) []string

FilterBasedOnPercentage return the slice of list based on the the provided percentage

func FilterNonChaosPods

func FilterNonChaosPods(clients clients.ClientSets, chaosDetails *types.ChaosDetails) (core_v1.PodList, error)

FilterNonChaosPods remove the chaos pods(operator, runner) for the podList it filter when the applabels are not defined and it will select random pods from appns

func GetContainerID

func GetContainerID(appNamespace, targetPod, targetContainer string, clients clients.ClientSets) (string, error)

GetContainerID derive the container id of the application container

func GetHelperLabels

func GetHelperLabels(labels map[string]string, runID, labelSuffix, experimentName string) map[string]string

GetHelperLabels return the labels of the helper pod

func GetIterations

func GetIterations(duration, interval int) int

GetIterations derive the iterations value from given parameters

func GetNodeList

func GetNodeList(nodeNames, nodeLabel string, nodeAffPerc int, clients clients.ClientSets) ([]string, error)

GetNodeList check for the availibilty of the application node for the chaos execution if the application node is not defined it will derive the random target node list using node affected percentage

func GetNodeName

func GetNodeName(namespace, labels, nodeLabel string, clients clients.ClientSets) (string, error)

GetNodeName will select a random replica of application pod and return the node name of that application pod

func GetPID

func GetPID(runtime, containerID, socketPath string) (int, error)

GetPID extract out the PID of the target container

func GetPodList

func GetPodList(targetPods string, podAffPerc int, clients clients.ClientSets, chaosDetails *types.ChaosDetails) (core_v1.PodList, error)

GetPodList check for the availibilty of the target pod for the chaos execution if the target pod is not defined it will derive the random target pod list using pod affected percentage

func GetRunID

func GetRunID() string

GetRunID generate a random string

func GetServiceAccount

func GetServiceAccount(chaosNamespace, chaosPodName string, clients clients.ClientSets) (string, error)

GetServiceAccount derive the serviceAccountName for the helper pod

func GetStatusMessage

func GetStatusMessage(defaultCheck bool, defaultMsg, probeStatus string) string

GetStatusMessage returns the event message

func GetTargetContainer

func GetTargetContainer(appNamespace, appName string, clients clients.ClientSets) (string, error)

GetTargetContainer will fetch the container name from application pod This container will be used as target container

func GetTargetPodsWhenTargetPodsENVNotSet

func GetTargetPodsWhenTargetPodsENVNotSet(podAffPerc int, clients clients.ClientSets, nonChaosPods core_v1.PodList, chaosDetails *types.ChaosDetails) (core_v1.PodList, error)

GetTargetPodsWhenTargetPodsENVNotSet derives the random target pod list, if TARGET_PODS env is not set

func GetTargetPodsWhenTargetPodsENVSet

func GetTargetPodsWhenTargetPodsENVSet(targetPods string, clients clients.ClientSets, chaosDetails *types.ChaosDetails) (core_v1.PodList, error)

GetTargetPodsWhenTargetPodsENVSet derive the specific target pods, if TARGET_PODS env is set

func HelperFailedError

func HelperFailedError(err error) error

HelperFailedError return the helper pod error message

func PostChaosActiveNodeCountCheck

func PostChaosActiveNodeCountCheck(activeNodeCount, timeout, delay int, clients clients.ClientSets) error

PostChaosActiveNodeCountCheck checks the number of active nodes post chaos and validates the number of healthy node count post chaos

func PreChaosNodeStatusCheck

func PreChaosNodeStatusCheck(timeout, delay int, clients clients.ClientSets) (int, error)

PreChaosNodeStatusCheck fetches all the nodes in the cluster and checks their status, and fetches the total active nodes in the cluster, prior to the chaos experiment

func RandomInterval

func RandomInterval(interval string) error

RandomInterval wait for the random interval lies between lower & upper bounds

func SetHelperData

func SetHelperData(chaosDetails *types.ChaosDetails, clients clients.ClientSets) error

SetHelperData derive the data from experiment pod and sets into experimentDetails struct which can be used to create helper pod

func SetParentName

func SetParentName(parentName string, chaosDetails *types.ChaosDetails)

SetParentName set the parent name in chaosdetails struct

func SetTargets

func SetTargets(target, chaosStatus, kind string, chaosDetails *types.ChaosDetails)

SetTargets set the target details in chaosdetails struct

func VerifyExistanceOfPods

func VerifyExistanceOfPods(namespace, pods string, clients clients.ClientSets) (bool, error)

VerifyExistanceOfPods check the availibility of list of pods

func WaitForDuration

func WaitForDuration(duration int)

WaitForDuration waits for the given time duration (in seconds)

Types

type CrictlInspectResponse

type CrictlInspectResponse struct {
	Info InfoDetails `json:"info"`
}

CrictlInspectResponse JSON representation of crictl inspect command output in crio, pid is present inside pid attribute of inspect output in containerd, pid is present inside `info.pid` of inspect output

type DockerInspectResponse

type DockerInspectResponse struct {
	State StateDetails `json:"state"`
}

DockerInspectResponse JSON representation of docker inspect command output

type ENVDetails

type ENVDetails struct {
	ENV []apiv1.EnvVar
}

ENVDetails contains the ENV details

func (*ENVDetails) SetEnv

func (envDetails *ENVDetails) SetEnv(key, value string) *ENVDetails

SetEnv sets the env inside envDetails struct

func (*ENVDetails) SetEnvFromDownwardAPI

func (envDetails *ENVDetails) SetEnvFromDownwardAPI(apiVersion string, fieldPath string) *ENVDetails

SetEnvFromDownwardAPI sets the downapi env in envDetails struct

type InfoDetails

type InfoDetails struct {
	RuntimeSpec RuntimeDetails `json:"runtimeSpec"`
	PID         int            `json:"pid"`
}

InfoDetails JSON representation of crictl inspect command output

type LinuxAttributes

type LinuxAttributes struct {
	Namespaces []Namespace `json:"namespaces"`
}

LinuxAttributes contains all the linux attributes

type Namespace

type Namespace struct {
	Type string `json:"type"`
	Path string `json:"path"`
}

Namespace contains linux namespace details

type RuntimeDetails

type RuntimeDetails struct {
	Linux LinuxAttributes `json:"linux"`
}

RuntimeDetails contains runtime details

type StateDetails

type StateDetails struct {
	PID int `json:"pid"`
}

StateDetails JSON representation of docker inspect command output

Jump to

Keyboard shortcuts

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