diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf5d04ba7..d8e4a89e9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: create: tags: - - 'v*' + - '**' jobs: lint: @@ -55,7 +55,7 @@ jobs: - name: Set Tag run: | - TAG="${GITHUB_REF#refs/*/v}" + TAG="${GITHUB_REF#refs/*/}" echo "TAG=${TAG}" >> $GITHUB_ENV echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV diff --git a/chaoslib/litmus/pod-cpu-hog/lib/pod-cpu-hog.go b/chaoslib/litmus/pod-cpu-hog/lib/pod-cpu-hog.go index 624334dce..7216ba4ee 100644 --- a/chaoslib/litmus/pod-cpu-hog/lib/pod-cpu-hog.go +++ b/chaoslib/litmus/pod-cpu-hog/lib/pod-cpu-hog.go @@ -24,15 +24,16 @@ import ( // StressCPU Uses the REST API to exec into the target container of the target pod // The function will be constantly increasing the CPU utilisation until it reaches the maximum available or allowed number. // Using the TOTAL_CHAOS_DURATION we will need to specify for how long this experiment will last -func StressCPU(containerName, podName, namespace, cpuHogCmd string, clients clients.ClientSets) error { +func StressCPU(experimentsDetails *experimentTypes.ExperimentDetails, podName string, clients clients.ClientSets) error { // It will contains all the pod & container details required for exec command execCommandDetails := litmusexec.PodDetails{} - command := []string{"/bin/sh", "-c", cpuHogCmd} - litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, containerName, namespace) + command := []string{"/bin/sh", "-c", experimentsDetails.ChaosInjectCmd} + litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, experimentsDetails.TargetContainer, experimentsDetails.AppNS) _, err := litmusexec.Exec(&execCommandDetails, clients, command) if err != nil { return errors.Errorf("Unable to run stress command inside target container, err: %v", err) } + return nil } @@ -85,7 +86,9 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai "Pod": pod.Name, "CPU CORE": experimentsDetails.CPUcores, }) - go StressCPU(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosInjectCmd, clients) + for i := 0; i < experimentsDetails.CPUcores; i++ { + go StressCPU(experimentsDetails, pod.Name, clients) + } log.Infof("[Chaos]:Waiting for: %vs", experimentsDetails.ChaosDuration) @@ -99,7 +102,7 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai select { case <-signChan: log.Info("[Chaos]: Killing process started because of terminated signal received") - err := KillStressCPUSerial(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients) + err := KillStressCPUSerial(experimentsDetails, pod.Name, clients) if err != nil { klog.V(0).Infof("Error in Kill stress after abortion") return err @@ -124,7 +127,7 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai break loop } } - if err := KillStressCPUSerial(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients); err != nil { + if err := KillStressCPUSerial(experimentsDetails, pod.Name, clients); err != nil { return err } } @@ -150,7 +153,9 @@ func InjectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet "CPU CORE": experimentsDetails.CPUcores, }) - go StressCPU(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosInjectCmd, clients) + for i := 0; i < experimentsDetails.CPUcores; i++ { + go StressCPU(experimentsDetails, pod.Name, clients) + } } log.Infof("[Chaos]:Waiting for: %vs", experimentsDetails.ChaosDuration) @@ -165,7 +170,7 @@ loop: select { case <-signChan: log.Info("[Chaos]: Killing process started because of terminated signal received") - err := KillStressCPUParallel(experimentsDetails.TargetContainer, targetPodList, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients) + err := KillStressCPUParallel(experimentsDetails, targetPodList, clients) if err != nil { klog.V(0).Infof("Error in Kill stress after abortion") return err @@ -190,7 +195,7 @@ loop: break loop } } - if err := KillStressCPUParallel(experimentsDetails.TargetContainer, targetPodList, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients); err != nil { + if err := KillStressCPUParallel(experimentsDetails, targetPodList, clients); err != nil { return err } @@ -231,13 +236,13 @@ func GetTargetContainer(experimentsDetails *experimentTypes.ExperimentDetails, a // KillStressCPUSerial function to kill a stress process running inside target container // Triggered by either timeout of chaos duration or termination of the experiment -func KillStressCPUSerial(containerName, podName, namespace, cpuFreeCmd string, clients clients.ClientSets) error { +func KillStressCPUSerial(experimentsDetails *experimentTypes.ExperimentDetails, podName string, clients clients.ClientSets) error { // It will contains all the pod & container details required for exec command execCommandDetails := litmusexec.PodDetails{} - command := []string{"/bin/sh", "-c", cpuFreeCmd} + command := []string{"/bin/sh", "-c", experimentsDetails.ChaosKillCmd} - litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, containerName, namespace) + litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, experimentsDetails.TargetContainer, experimentsDetails.AppNS) _, err := litmusexec.Exec(&execCommandDetails, clients, command) if err != nil { return errors.Errorf("Unable to kill the stress process in %v pod, err: %v", podName, err) @@ -248,11 +253,11 @@ func KillStressCPUSerial(containerName, podName, namespace, cpuFreeCmd string, c // KillStressCPUParallel function to kill all the stress process running inside target container // Triggered by either timeout of chaos duration or termination of the experiment -func KillStressCPUParallel(containerName string, targetPodList corev1.PodList, namespace, cpuFreeCmd string, clients clients.ClientSets) error { +func KillStressCPUParallel(experimentsDetails *experimentTypes.ExperimentDetails, targetPodList corev1.PodList, clients clients.ClientSets) error { for _, pod := range targetPodList.Items { - if err := KillStressCPUSerial(containerName, pod.Name, namespace, cpuFreeCmd, clients); err != nil { + if err := KillStressCPUSerial(experimentsDetails, pod.Name, clients); err != nil { return err } } diff --git a/go.mod b/go.mod index 0cdf8fdf4..3d03900e1 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/imdario/mergo v0.3.9 // indirect github.com/kr/pretty v0.2.0 // indirect github.com/kyokomi/emoji v2.2.4+incompatible - github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e + github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8 github.com/mailru/easyjson v0.7.1 // indirect github.com/openebs/maya v0.0.0-20200411140727-1c81f9e017b0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index b0a645ddb..bda3d6663 100644 --- a/go.sum +++ b/go.sum @@ -476,6 +476,8 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9 github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc= github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e h1:ubIPSIWT4le0PZZ4MrALdgkiIVmGrz0YzYeWWvSC2a4= github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e/go.mod h1:Z2GpYjqXwFd8bx+kv58YEQFxynx1v9PMGCGTQFRVnFQ= +github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8 h1:aEpAyowpCm1lgMoWLcO4Han0yp2WvLuRzKHVKxjvJr0= +github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8/go.mod h1:Z2GpYjqXwFd8bx+kv58YEQFxynx1v9PMGCGTQFRVnFQ= github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c/go.mod h1:DsbHGNUq/78NZozWVVI9Q6eBei4I+JjlkkD5aibJ3MQ= github.com/lpabon/godbc v0.1.1/go.mod h1:Jo9QV0cf3U6jZABgiJ2skINAXb9j8m51r07g4KI92ZA= github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f h1:sSeNEkJrs+0F9TUau0CgWTTNEwF23HST3Eq0A+QIx+A= diff --git a/pkg/cassandra/pod-delete/environment/environment.go b/pkg/cassandra/pod-delete/environment/environment.go index af50cf4af..b74cab302 100644 --- a/pkg/cassandra/pod-delete/environment/environment.go +++ b/pkg/cassandra/pod-delete/environment/environment.go @@ -71,4 +71,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, cassandraDetails chaosDetails.Timeout = cassandraDetails.ChaoslibDetail.Timeout chaosDetails.Delay = cassandraDetails.ChaoslibDetail.Delay chaosDetails.AppDetail = appDetails + chaosDetails.ProbeImagePullPolicy = cassandraDetails.ChaoslibDetail.LIBImagePullPolicy } diff --git a/pkg/generic/disk-fill/environment/environment.go b/pkg/generic/disk-fill/environment/environment.go index 35a2b14bd..70937776b 100644 --- a/pkg/generic/disk-fill/environment/environment.go +++ b/pkg/generic/disk-fill/environment/environment.go @@ -66,4 +66,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Delay = experimentDetails.Delay chaosDetails.AppDetail = appDetails chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/kubelet-service-kill/environment/environment.go b/pkg/generic/kubelet-service-kill/environment/environment.go index eff15e978..d6adedfd4 100644 --- a/pkg/generic/kubelet-service-kill/environment/environment.go +++ b/pkg/generic/kubelet-service-kill/environment/environment.go @@ -53,4 +53,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/network-chaos/environment/environment.go b/pkg/generic/network-chaos/environment/environment.go index e263550c2..f607983d3 100644 --- a/pkg/generic/network-chaos/environment/environment.go +++ b/pkg/generic/network-chaos/environment/environment.go @@ -75,4 +75,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.ChaosDuration = experimentDetails.ChaosDuration chaosDetails.AppDetail = appDetails chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/network-latency/environment/environment.go b/pkg/generic/network-latency/environment/environment.go index 8e9edf1e1..4ff9dcc2d 100644 --- a/pkg/generic/network-latency/environment/environment.go +++ b/pkg/generic/network-latency/environment/environment.go @@ -104,4 +104,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.InstanceID = experimentDetails.InstanceID chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/network-latency/types/types.go b/pkg/generic/network-latency/types/types.go index 4b70650da..8653f52f4 100644 --- a/pkg/generic/network-latency/types/types.go +++ b/pkg/generic/network-latency/types/types.go @@ -7,26 +7,27 @@ import ( // ExperimentDetails is for collecting all the experiment-related details type ExperimentDetails struct { - ExperimentName string - EngineName string - ChaosDuration int - ChaosInterval int - RampTime int - ChaosLib string - ChaosServiceAccount string - AppNS string - AppLabel string - AppKind string - ChaosUID clientTypes.UID - AuxiliaryAppInfo string - InstanceID string - ChaosNamespace string - ChaosPodName string - Latency float64 - Jitter float64 - ChaosNode string - Timeout int - Delay int + ExperimentName string + EngineName string + ChaosDuration int + ChaosInterval int + RampTime int + ChaosLib string + ChaosServiceAccount string + AppNS string + AppLabel string + AppKind string + ChaosUID clientTypes.UID + AuxiliaryAppInfo string + InstanceID string + ChaosNamespace string + ChaosPodName string + Latency float64 + Jitter float64 + ChaosNode string + Timeout int + Delay int + LIBImagePullPolicy string } // Definition is the chaos experiment definition coming from a user input file. diff --git a/pkg/generic/node-cpu-hog/environment/environment.go b/pkg/generic/node-cpu-hog/environment/environment.go index 495658216..fa299ed4a 100644 --- a/pkg/generic/node-cpu-hog/environment/environment.go +++ b/pkg/generic/node-cpu-hog/environment/environment.go @@ -55,4 +55,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/node-drain/environment/environment.go b/pkg/generic/node-drain/environment/environment.go index 01dfa3d5a..3d1d8e85c 100644 --- a/pkg/generic/node-drain/environment/environment.go +++ b/pkg/generic/node-drain/environment/environment.go @@ -51,4 +51,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.InstanceID = experimentDetails.InstanceID chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/node-drain/types/types.go b/pkg/generic/node-drain/types/types.go index da754da63..588357775 100644 --- a/pkg/generic/node-drain/types/types.go +++ b/pkg/generic/node-drain/types/types.go @@ -6,20 +6,21 @@ import ( // ExperimentDetails is for collecting all the experiment-related details type ExperimentDetails struct { - ExperimentName string - EngineName string - ChaosDuration int - RampTime int - ChaosLib string - AppNS string - AppLabel string - AppKind string - ChaosUID clientTypes.UID - InstanceID string - ChaosNamespace string - ChaosPodName string - TargetNode string - AuxiliaryAppInfo string - Timeout int - Delay int + ExperimentName string + EngineName string + ChaosDuration int + RampTime int + ChaosLib string + AppNS string + AppLabel string + AppKind string + ChaosUID clientTypes.UID + InstanceID string + ChaosNamespace string + ChaosPodName string + TargetNode string + AuxiliaryAppInfo string + Timeout int + Delay int + LIBImagePullPolicy string } diff --git a/pkg/generic/node-io-stress/environment/environment.go b/pkg/generic/node-io-stress/environment/environment.go index f14d5d3ea..c51c8ecb5 100644 --- a/pkg/generic/node-io-stress/environment/environment.go +++ b/pkg/generic/node-io-stress/environment/environment.go @@ -57,4 +57,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/node-memory-hog/environment/environment.go b/pkg/generic/node-memory-hog/environment/environment.go index 117c631a8..92ad187f5 100644 --- a/pkg/generic/node-memory-hog/environment/environment.go +++ b/pkg/generic/node-memory-hog/environment/environment.go @@ -55,4 +55,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/node-restart/environment/environment.go b/pkg/generic/node-restart/environment/environment.go index f74dd4187..92cba542b 100644 --- a/pkg/generic/node-restart/environment/environment.go +++ b/pkg/generic/node-restart/environment/environment.go @@ -55,4 +55,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/node-taint/environment/environment.go b/pkg/generic/node-taint/environment/environment.go index c24fc7c08..3d73d5edc 100644 --- a/pkg/generic/node-taint/environment/environment.go +++ b/pkg/generic/node-taint/environment/environment.go @@ -52,4 +52,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.InstanceID = experimentDetails.InstanceID chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/node-taint/types/types.go b/pkg/generic/node-taint/types/types.go index dc9f666c9..cae52441e 100644 --- a/pkg/generic/node-taint/types/types.go +++ b/pkg/generic/node-taint/types/types.go @@ -6,21 +6,22 @@ import ( // ExperimentDetails is for collecting all the experiment-related details type ExperimentDetails struct { - ExperimentName string - EngineName string - RampTime int - ChaosDuration int - ChaosLib string - AppNS string - AppLabel string - AppKind string - ChaosUID clientTypes.UID - InstanceID string - ChaosNamespace string - ChaosPodName string - TargetNode string - AuxiliaryAppInfo string - Taints string - Timeout int - Delay int + ExperimentName string + EngineName string + RampTime int + ChaosDuration int + ChaosLib string + AppNS string + AppLabel string + AppKind string + ChaosUID clientTypes.UID + InstanceID string + ChaosNamespace string + ChaosPodName string + TargetNode string + AuxiliaryAppInfo string + Taints string + Timeout int + Delay int + LIBImagePullPolicy string } diff --git a/pkg/generic/pod-autoscaler/environment/environment.go b/pkg/generic/pod-autoscaler/environment/environment.go index e419a7537..05e9035dc 100644 --- a/pkg/generic/pod-autoscaler/environment/environment.go +++ b/pkg/generic/pod-autoscaler/environment/environment.go @@ -48,5 +48,6 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.EngineName = experimentDetails.EngineName chaosDetails.ExperimentName = experimentDetails.ExperimentName chaosDetails.InstanceID = experimentDetails.InstanceID + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/pod-autoscaler/types/types.go b/pkg/generic/pod-autoscaler/types/types.go index e2641b8f0..6833d02dd 100644 --- a/pkg/generic/pod-autoscaler/types/types.go +++ b/pkg/generic/pod-autoscaler/types/types.go @@ -24,6 +24,7 @@ type ExperimentDetails struct { AuxiliaryAppInfo string Timeout int Delay int + LIBImagePullPolicy string } // ApplicationUnderTest contains the name of the deployment object and the current replica count diff --git a/pkg/generic/pod-cpu-hog/environment/environment.go b/pkg/generic/pod-cpu-hog/environment/environment.go index c2e1ea127..8972ef08d 100644 --- a/pkg/generic/pod-cpu-hog/environment/environment.go +++ b/pkg/generic/pod-cpu-hog/environment/environment.go @@ -30,7 +30,7 @@ func GetENV(experimentDetails *experimentTypes.ExperimentDetails) { experimentDetails.Timeout, _ = strconv.Atoi(Getenv("STATUS_CHECK_TIMEOUT", "180")) experimentDetails.TargetPods = Getenv("TARGET_PODS", "") experimentDetails.ChaosInjectCmd = Getenv("CHAOS_INJECT_COMMAND", "md5sum /dev/zero") - experimentDetails.ChaosKillCmd = Getenv("CHAOS_KILL_COMMAND", "kill $(find /proc -name exe -lname '*/md5sum' 2>&1 | grep -v 'Permission denied' | awk -F/ '{print $(NF-1)}' | head -n 1)") + experimentDetails.ChaosKillCmd = Getenv("CHAOS_KILL_COMMAND", "kill $(find /proc -name exe -lname '*/md5sum' 2>&1 | grep -v 'Permission denied' | awk -F/ '{print $(NF-1)}')") experimentDetails.LIBImage = Getenv("LIB_IMAGE", "gaiaadm/pumba") experimentDetails.LIBImagePullPolicy = Getenv("LIB_IMAGE_PULL_POLICY", "Always") experimentDetails.TargetContainer = Getenv("TARGET_CONTAINER", "") @@ -67,4 +67,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.AppDetail = appDetails + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/pod-delete/environment/environment.go b/pkg/generic/pod-delete/environment/environment.go index 16766754e..348e93dbf 100644 --- a/pkg/generic/pod-delete/environment/environment.go +++ b/pkg/generic/pod-delete/environment/environment.go @@ -62,4 +62,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.AppDetail = appDetails + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/pod-delete/types/types.go b/pkg/generic/pod-delete/types/types.go index 0c7ec3113..5c938229c 100644 --- a/pkg/generic/pod-delete/types/types.go +++ b/pkg/generic/pod-delete/types/types.go @@ -27,4 +27,5 @@ type ExperimentDetails struct { TargetPods string PodsAffectedPerc int Sequence string + LIBImagePullPolicy string } diff --git a/pkg/generic/pod-io-stress/environment/environment.go b/pkg/generic/pod-io-stress/environment/environment.go index f92669ab6..9445b1d8c 100644 --- a/pkg/generic/pod-io-stress/environment/environment.go +++ b/pkg/generic/pod-io-stress/environment/environment.go @@ -67,4 +67,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Delay = experimentDetails.Delay chaosDetails.AppDetail = appDetails chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain") + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/generic/pod-memory-hog/environment/environment.go b/pkg/generic/pod-memory-hog/environment/environment.go index 103d4ca7d..abf211cfc 100644 --- a/pkg/generic/pod-memory-hog/environment/environment.go +++ b/pkg/generic/pod-memory-hog/environment/environment.go @@ -65,4 +65,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay chaosDetails.AppDetail = appDetails + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/kafka/environment/environment.go b/pkg/kafka/environment/environment.go index 56611f275..23c99fa52 100644 --- a/pkg/kafka/environment/environment.go +++ b/pkg/kafka/environment/environment.go @@ -82,4 +82,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, kafkaDetails *ka chaosDetails.Timeout = kafkaDetails.ChaoslibDetail.Timeout chaosDetails.Delay = kafkaDetails.ChaoslibDetail.Delay chaosDetails.AppDetail = appDetails + chaosDetails.ProbeImagePullPolicy = kafkaDetails.ChaoslibDetail.LIBImagePullPolicy } diff --git a/pkg/kube-aws/ebs-loss/environment/environment.go b/pkg/kube-aws/ebs-loss/environment/environment.go index a6e8bbd36..b622f5c83 100644 --- a/pkg/kube-aws/ebs-loss/environment/environment.go +++ b/pkg/kube-aws/ebs-loss/environment/environment.go @@ -53,4 +53,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.InstanceID = experimentDetails.InstanceID chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/kube-aws/ebs-loss/types/types.go b/pkg/kube-aws/ebs-loss/types/types.go index 02e40f0d0..558af0579 100644 --- a/pkg/kube-aws/ebs-loss/types/types.go +++ b/pkg/kube-aws/ebs-loss/types/types.go @@ -6,24 +6,25 @@ import ( // ExperimentDetails is for collecting all the experiment-related details type ExperimentDetails struct { - ExperimentName string - EngineName string - ChaosDuration int - RampTime int - ChaosLib string - AppNS string - AppLabel string - AppKind string - ChaosUID clientTypes.UID - InstanceID string - ChaosNamespace string - ChaosPodName string - AuxiliaryAppInfo string - RunID string - Timeout int - Delay int - Ec2InstanceID string - EBSVolumeID string - DeviceName string - Region string + ExperimentName string + EngineName string + ChaosDuration int + RampTime int + ChaosLib string + AppNS string + AppLabel string + AppKind string + ChaosUID clientTypes.UID + InstanceID string + ChaosNamespace string + ChaosPodName string + AuxiliaryAppInfo string + RunID string + Timeout int + Delay int + Ec2InstanceID string + EBSVolumeID string + DeviceName string + Region string + LIBImagePullPolicy string } diff --git a/pkg/kube-aws/ec2-terminate/environment/environment.go b/pkg/kube-aws/ec2-terminate/environment/environment.go index 462458813..21574e31d 100644 --- a/pkg/kube-aws/ec2-terminate/environment/environment.go +++ b/pkg/kube-aws/ec2-terminate/environment/environment.go @@ -51,4 +51,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail chaosDetails.InstanceID = experimentDetails.InstanceID chaosDetails.Timeout = experimentDetails.Timeout chaosDetails.Delay = experimentDetails.Delay + chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy } diff --git a/pkg/kube-aws/ec2-terminate/types/types.go b/pkg/kube-aws/ec2-terminate/types/types.go index 15955faef..c8e27ad55 100644 --- a/pkg/kube-aws/ec2-terminate/types/types.go +++ b/pkg/kube-aws/ec2-terminate/types/types.go @@ -6,21 +6,22 @@ import ( // ExperimentDetails is for collecting all the experiment-related details type ExperimentDetails struct { - ExperimentName string - EngineName string - RampTime int - AppNS string - AppLabel string - AppKind string - AuxiliaryAppInfo string - ChaosLib string - ChaosDuration int - ChaosUID clientTypes.UID - InstanceID string - ChaosNamespace string - ChaosPodName string - Timeout int - Delay int - Ec2InstanceID string - Region string + ExperimentName string + EngineName string + RampTime int + AppNS string + AppLabel string + AppKind string + AuxiliaryAppInfo string + ChaosLib string + ChaosDuration int + ChaosUID clientTypes.UID + InstanceID string + ChaosNamespace string + ChaosPodName string + Timeout int + Delay int + Ec2InstanceID string + Region string + LIBImagePullPolicy string } diff --git a/pkg/probe/httpprobe.go b/pkg/probe/httpprobe.go index d0adededc..2a4d55474 100644 --- a/pkg/probe/httpprobe.go +++ b/pkg/probe/httpprobe.go @@ -5,6 +5,7 @@ import ( "time" "net/http" + "crypto/tls" "github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1" "github.com/litmuschaos/litmus-go/pkg/clients" @@ -54,11 +55,24 @@ func TriggerHTTPProbe(probe v1alpha1.ProbeAttributes, resultDetails *types.Resul Timeout(int64(probe.RunProperties.ProbeTimeout)). Wait(time.Duration(probe.RunProperties.Interval) * time.Second). TryWithTimeout(func(attempt uint) error { + + // initialize simple http client with default attributes + client := &http.Client{} + + // impose properties to http client with cert check disabled + if probe.HTTPProbeInputs.InsecureSkipVerify { + transCfg := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + client = &http.Client{Transport: transCfg} + } + // getting the response from the given url - resp, err := http.Get(probe.HTTPProbeInputs.URL) + resp, err := client.Get(probe.HTTPProbeInputs.URL) if err != nil { return err } + code, _ := strconv.Atoi(probe.HTTPProbeInputs.ExpectedResponseCode) // matching the status code w/ expected code if resp.StatusCode != code { diff --git a/pkg/status/application.go b/pkg/status/application.go index bf46ecc9d..28d9eabab 100644 --- a/pkg/status/application.go +++ b/pkg/status/application.go @@ -53,11 +53,11 @@ func CheckPodStatusPhase(appNs, appLabel string, timeout, delay int, clients cli Times(uint(timeout / delay)). Wait(time.Duration(delay) * time.Second). Try(func(attempt uint) error { - podSpec, err := clients.KubeClient.CoreV1().Pods(appNs).List(metav1.ListOptions{LabelSelector: appLabel}) - if err != nil || len(podSpec.Items) == 0 { + podList, err := clients.KubeClient.CoreV1().Pods(appNs).List(metav1.ListOptions{LabelSelector: appLabel}) + if err != nil || len(podList.Items) == 0 { return errors.Errorf("Unable to find the pods with matching labels, err: %v", err) } - for _, pod := range podSpec.Items { + for _, pod := range podList.Items { isInState := false for _, state := range states { if string(pod.Status.Phase) == state { @@ -66,7 +66,7 @@ func CheckPodStatusPhase(appNs, appLabel string, timeout, delay int, clients cli } } if !isInState { - return errors.Errorf("Pod is not yet in targeted state") + return errors.Errorf("Pod is not yet in %v state(s)", states) } log.InfoWithValues("[Status]: The status of Pods are as follows", logrus.Fields{ "Pod": pod.Name, "Status": pod.Status.Phase}) @@ -91,11 +91,11 @@ func CheckContainerStatus(appNs, appLabel string, timeout, delay int, clients cl Times(uint(timeout / delay)). Wait(time.Duration(delay) * time.Second). Try(func(attempt uint) error { - podSpec, err := clients.KubeClient.CoreV1().Pods(appNs).List(metav1.ListOptions{LabelSelector: appLabel}) - if err != nil || len(podSpec.Items) == 0 { + podList, err := clients.KubeClient.CoreV1().Pods(appNs).List(metav1.ListOptions{LabelSelector: appLabel}) + if err != nil || len(podList.Items) == 0 { return errors.Errorf("Unable to find the pods with matching labels, err: %v", err) } - for _, pod := range podSpec.Items { + for _, pod := range podList.Items { for _, container := range pod.Status.ContainerStatuses { if container.State.Terminated != nil { return errors.Errorf("container is in terminated state") @@ -124,15 +124,15 @@ func WaitForCompletion(appNs, appLabel string, clients clients.ClientSets, durat Times(uint(duration)). Wait(1 * time.Second). Try(func(attempt uint) error { - podSpec, err := clients.KubeClient.CoreV1().Pods(appNs).List(metav1.ListOptions{LabelSelector: appLabel}) - if err != nil || len(podSpec.Items) == 0 { + podList, err := clients.KubeClient.CoreV1().Pods(appNs).List(metav1.ListOptions{LabelSelector: appLabel}) + if err != nil || len(podList.Items) == 0 { return errors.Errorf("Unable to find the pods with matching labels, err: %v", err) } // it will check for the status of helper pod, if it is Succeeded and target container is completed then it will marked it as completed and return // if it is still running then it will check for the target container, as we can have multiple container inside helper pod (istio) // if the target container is in completed state(ready flag is false), then we will marked the helper pod as completed // we will retry till it met the timeout(chaos duration) - for _, pod := range podSpec.Items { + for _, pod := range podList.Items { podStatus = string(pod.Status.Phase) log.Infof("helper pod status: %v", podStatus) if podStatus != "Succeeded" && podStatus != "Failed" { diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE b/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE deleted file mode 100644 index 14127cd83..000000000 --- a/vendor/github.com/konsorten/go-windows-terminal-sequences/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -(The MIT License) - -Copyright (c) 2017 marvin + konsorten GmbH (open-source@konsorten.de) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md b/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md deleted file mode 100644 index 09a4a35c9..000000000 --- a/vendor/github.com/konsorten/go-windows-terminal-sequences/README.md +++ /dev/null @@ -1,42 +0,0 @@ -# Windows Terminal Sequences - -This library allow for enabling Windows terminal color support for Go. - -See [Console Virtual Terminal Sequences](https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences) for details. - -## Usage - -```go -import ( - "syscall" - - sequences "github.com/konsorten/go-windows-terminal-sequences" -) - -func main() { - sequences.EnableVirtualTerminalProcessing(syscall.Stdout, true) -} - -``` - -## Authors - -The tool is sponsored by the [marvin + konsorten GmbH](http://www.konsorten.de). - -We thank all the authors who provided code to this library: - -* Felix Kollmann -* Nicolas Perraut -* @dirty49374 - -## License - -(The MIT License) - -Copyright (c) 2018 marvin + konsorten GmbH (open-source@konsorten.de) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod b/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod deleted file mode 100644 index 716c61312..000000000 --- a/vendor/github.com/konsorten/go-windows-terminal-sequences/go.mod +++ /dev/null @@ -1 +0,0 @@ -module github.com/konsorten/go-windows-terminal-sequences diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go deleted file mode 100644 index 57f530ae8..000000000 --- a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences.go +++ /dev/null @@ -1,35 +0,0 @@ -// +build windows - -package sequences - -import ( - "syscall" -) - -var ( - kernel32Dll *syscall.LazyDLL = syscall.NewLazyDLL("Kernel32.dll") - setConsoleMode *syscall.LazyProc = kernel32Dll.NewProc("SetConsoleMode") -) - -func EnableVirtualTerminalProcessing(stream syscall.Handle, enable bool) error { - const ENABLE_VIRTUAL_TERMINAL_PROCESSING uint32 = 0x4 - - var mode uint32 - err := syscall.GetConsoleMode(syscall.Stdout, &mode) - if err != nil { - return err - } - - if enable { - mode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING - } else { - mode &^= ENABLE_VIRTUAL_TERMINAL_PROCESSING - } - - ret, _, err := setConsoleMode.Call(uintptr(stream), uintptr(mode)) - if ret == 0 { - return err - } - - return nil -} diff --git a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go b/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go deleted file mode 100644 index df61a6f2f..000000000 --- a/vendor/github.com/konsorten/go-windows-terminal-sequences/sequences_dummy.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build linux darwin - -package sequences - -import ( - "fmt" -) - -func EnableVirtualTerminalProcessing(stream uintptr, enable bool) error { - return fmt.Errorf("windows only package") -} diff --git a/vendor/github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1/chaosengine_types.go b/vendor/github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1/chaosengine_types.go index 3d415ae26..a277a5466 100644 --- a/vendor/github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1/chaosengine_types.go +++ b/vendor/github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1/chaosengine_types.go @@ -265,6 +265,8 @@ type ComparatorInfo struct { type HTTPProbeInputs struct { // URL which needs to curl, to check the status URL string `json:"url,omitempty"` + // InsecureSkipVerify flag to skip certificate checks + InsecureSkipVerify bool `json:"insecureSkipVerify,omitempty"` // Expected response code from the given url ExpectedResponseCode string `json:"expectedResponseCode,omitempty"` } diff --git a/vendor/github.com/sirupsen/logrus/.gitignore b/vendor/github.com/sirupsen/logrus/.gitignore index 6b7d7d1e8..1fb13abeb 100644 --- a/vendor/github.com/sirupsen/logrus/.gitignore +++ b/vendor/github.com/sirupsen/logrus/.gitignore @@ -1,2 +1,4 @@ logrus vendor + +.idea/ diff --git a/vendor/github.com/sirupsen/logrus/buffer_pool.go b/vendor/github.com/sirupsen/logrus/buffer_pool.go new file mode 100644 index 000000000..4545dec07 --- /dev/null +++ b/vendor/github.com/sirupsen/logrus/buffer_pool.go @@ -0,0 +1,52 @@ +package logrus + +import ( + "bytes" + "sync" +) + +var ( + bufferPool BufferPool +) + +type BufferPool interface { + Put(*bytes.Buffer) + Get() *bytes.Buffer +} + +type defaultPool struct { + pool *sync.Pool +} + +func (p *defaultPool) Put(buf *bytes.Buffer) { + p.pool.Put(buf) +} + +func (p *defaultPool) Get() *bytes.Buffer { + return p.pool.Get().(*bytes.Buffer) +} + +func getBuffer() *bytes.Buffer { + return bufferPool.Get() +} + +func putBuffer(buf *bytes.Buffer) { + buf.Reset() + bufferPool.Put(buf) +} + +// SetBufferPool allows to replace the default logrus buffer pool +// to better meets the specific needs of an application. +func SetBufferPool(bp BufferPool) { + bufferPool = bp +} + +func init() { + SetBufferPool(&defaultPool{ + pool: &sync.Pool{ + New: func() interface{} { + return new(bytes.Buffer) + }, + }, + }) +} diff --git a/vendor/github.com/sirupsen/logrus/entry.go b/vendor/github.com/sirupsen/logrus/entry.go index f6e062a34..5a5cbfe7c 100644 --- a/vendor/github.com/sirupsen/logrus/entry.go +++ b/vendor/github.com/sirupsen/logrus/entry.go @@ -13,7 +13,6 @@ import ( ) var ( - bufferPool *sync.Pool // qualified package name, cached at first use logrusPackage string @@ -31,12 +30,6 @@ const ( ) func init() { - bufferPool = &sync.Pool{ - New: func() interface{} { - return new(bytes.Buffer) - }, - } - // start at the bottom of the stack before the package-name cache is primed minimumCallerDepth = 1 } @@ -243,9 +236,12 @@ func (entry Entry) log(level Level, msg string) { entry.fireHooks() - buffer = bufferPool.Get().(*bytes.Buffer) + buffer = getBuffer() + defer func() { + entry.Buffer = nil + putBuffer(buffer) + }() buffer.Reset() - defer bufferPool.Put(buffer) entry.Buffer = buffer entry.write() diff --git a/vendor/github.com/sirupsen/logrus/exported.go b/vendor/github.com/sirupsen/logrus/exported.go index 42b04f6c8..017c30ce6 100644 --- a/vendor/github.com/sirupsen/logrus/exported.go +++ b/vendor/github.com/sirupsen/logrus/exported.go @@ -134,6 +134,51 @@ func Fatal(args ...interface{}) { std.Fatal(args...) } +// TraceFn logs a message from a func at level Trace on the standard logger. +func TraceFn(fn LogFunction) { + std.TraceFn(fn) +} + +// DebugFn logs a message from a func at level Debug on the standard logger. +func DebugFn(fn LogFunction) { + std.DebugFn(fn) +} + +// PrintFn logs a message from a func at level Info on the standard logger. +func PrintFn(fn LogFunction) { + std.PrintFn(fn) +} + +// InfoFn logs a message from a func at level Info on the standard logger. +func InfoFn(fn LogFunction) { + std.InfoFn(fn) +} + +// WarnFn logs a message from a func at level Warn on the standard logger. +func WarnFn(fn LogFunction) { + std.WarnFn(fn) +} + +// WarningFn logs a message from a func at level Warn on the standard logger. +func WarningFn(fn LogFunction) { + std.WarningFn(fn) +} + +// ErrorFn logs a message from a func at level Error on the standard logger. +func ErrorFn(fn LogFunction) { + std.ErrorFn(fn) +} + +// PanicFn logs a message from a func at level Panic on the standard logger. +func PanicFn(fn LogFunction) { + std.PanicFn(fn) +} + +// FatalFn logs a message from a func at level Fatal on the standard logger then the process will exit with status set to 1. +func FatalFn(fn LogFunction) { + std.FatalFn(fn) +} + // Tracef logs a message at level Trace on the standard logger. func Tracef(format string, args ...interface{}) { std.Tracef(format, args...) diff --git a/vendor/github.com/sirupsen/logrus/go.mod b/vendor/github.com/sirupsen/logrus/go.mod index d41329679..b3919d5ea 100644 --- a/vendor/github.com/sirupsen/logrus/go.mod +++ b/vendor/github.com/sirupsen/logrus/go.mod @@ -2,10 +2,9 @@ module github.com/sirupsen/logrus require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/konsorten/go-windows-terminal-sequences v1.0.3 github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/testify v1.2.2 - golang.org/x/sys v0.0.0-20190422165155-953cdadca894 + golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 ) go 1.13 diff --git a/vendor/github.com/sirupsen/logrus/go.sum b/vendor/github.com/sirupsen/logrus/go.sum index 49c690f23..1edc143be 100644 --- a/vendor/github.com/sirupsen/logrus/go.sum +++ b/vendor/github.com/sirupsen/logrus/go.sum @@ -1,12 +1,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/vendor/github.com/sirupsen/logrus/logger.go b/vendor/github.com/sirupsen/logrus/logger.go index 6fdda748e..dbf627c97 100644 --- a/vendor/github.com/sirupsen/logrus/logger.go +++ b/vendor/github.com/sirupsen/logrus/logger.go @@ -9,6 +9,11 @@ import ( "time" ) +// LogFunction For big messages, it can be more efficient to pass a function +// and only call it if the log level is actually enables rather than +// generating the log message and then checking if the level is enabled +type LogFunction func()[]interface{} + type Logger struct { // The logs are `io.Copy`'d to this in a mutex. It's common to set this to a // file, or leave it default which is `os.Stderr`. You can also set this to @@ -70,7 +75,7 @@ func (mw *MutexWrap) Disable() { // // var log = &logrus.Logger{ // Out: os.Stderr, -// Formatter: new(logrus.JSONFormatter), +// Formatter: new(logrus.TextFormatter), // Hooks: make(logrus.LevelHooks), // Level: logrus.DebugLevel, // } @@ -195,6 +200,14 @@ func (logger *Logger) Log(level Level, args ...interface{}) { } } +func (logger *Logger) LogFn(level Level, fn LogFunction) { + if logger.IsLevelEnabled(level) { + entry := logger.newEntry() + entry.Log(level, fn()...) + logger.releaseEntry(entry) + } +} + func (logger *Logger) Trace(args ...interface{}) { logger.Log(TraceLevel, args...) } @@ -234,6 +247,45 @@ func (logger *Logger) Panic(args ...interface{}) { logger.Log(PanicLevel, args...) } +func (logger *Logger) TraceFn(fn LogFunction) { + logger.LogFn(TraceLevel, fn) +} + +func (logger *Logger) DebugFn(fn LogFunction) { + logger.LogFn(DebugLevel, fn) +} + +func (logger *Logger) InfoFn(fn LogFunction) { + logger.LogFn(InfoLevel, fn) +} + +func (logger *Logger) PrintFn(fn LogFunction) { + entry := logger.newEntry() + entry.Print(fn()...) + logger.releaseEntry(entry) +} + +func (logger *Logger) WarnFn(fn LogFunction) { + logger.LogFn(WarnLevel, fn) +} + +func (logger *Logger) WarningFn(fn LogFunction) { + logger.WarnFn(fn) +} + +func (logger *Logger) ErrorFn(fn LogFunction) { + logger.LogFn(ErrorLevel, fn) +} + +func (logger *Logger) FatalFn(fn LogFunction) { + logger.LogFn(FatalLevel, fn) + logger.Exit(1) +} + +func (logger *Logger) PanicFn(fn LogFunction) { + logger.LogFn(PanicLevel, fn) +} + func (logger *Logger) Logln(level Level, args ...interface{}) { if logger.IsLevelEnabled(level) { entry := logger.newEntry() diff --git a/vendor/github.com/sirupsen/logrus/terminal_check_windows.go b/vendor/github.com/sirupsen/logrus/terminal_check_windows.go index 572889db2..2879eb50e 100644 --- a/vendor/github.com/sirupsen/logrus/terminal_check_windows.go +++ b/vendor/github.com/sirupsen/logrus/terminal_check_windows.go @@ -5,30 +5,23 @@ package logrus import ( "io" "os" - "syscall" - sequences "github.com/konsorten/go-windows-terminal-sequences" + "golang.org/x/sys/windows" ) -func initTerminal(w io.Writer) { - switch v := w.(type) { - case *os.File: - sequences.EnableVirtualTerminalProcessing(syscall.Handle(v.Fd()), true) - } -} - func checkIfTerminal(w io.Writer) bool { - var ret bool switch v := w.(type) { case *os.File: + handle := windows.Handle(v.Fd()) var mode uint32 - err := syscall.GetConsoleMode(syscall.Handle(v.Fd()), &mode) - ret = (err == nil) - default: - ret = false - } - if ret { - initTerminal(w) + if err := windows.GetConsoleMode(handle, &mode); err != nil { + return false + } + mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING + if err := windows.SetConsoleMode(handle, mode); err != nil { + return false + } + return true } - return ret + return false } diff --git a/vendor/modules.txt b/vendor/modules.txt index 24178521f..fb3dca173 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -75,11 +75,9 @@ github.com/inconshreveable/mousetrap github.com/jmespath/go-jmespath # github.com/json-iterator/go v1.1.9 github.com/json-iterator/go -# github.com/konsorten/go-windows-terminal-sequences v1.0.3 -github.com/konsorten/go-windows-terminal-sequences # github.com/kyokomi/emoji v2.2.4+incompatible github.com/kyokomi/emoji -# github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e +# github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8 github.com/litmuschaos/chaos-operator/pkg/apis/litmuschaos/v1alpha1 github.com/litmuschaos/chaos-operator/pkg/client/clientset/versioned/scheme github.com/litmuschaos/chaos-operator/pkg/client/clientset/versioned/typed/litmuschaos/v1alpha1 @@ -100,7 +98,7 @@ github.com/rs/zerolog github.com/rs/zerolog/internal/cbor github.com/rs/zerolog/internal/json github.com/rs/zerolog/log -# github.com/sirupsen/logrus v1.6.0 +# github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus # github.com/spf13/cobra v1.0.0 github.com/spf13/cobra