Skip to content

Commit e9ea060

Browse files
Karthik SatchitananduditgauravSamarSidharthispeakc0de
authored
[Cherry-pick for 1.11.3] (#260)
* Fix(actions): Fix Release build (#252) Signed-off-by: udit <udit.gaurav@mayadata.io> * Adding probe image pull policy var for all the experiments (#253) * Adding probe image pull policy var for all the experiments Signed-off-by: ipsita2192 <ipsita.das92@gmail.com> * (refactor)status checks: add expected app/pod state to log (#258) Signed-off-by: ksatchit <karthik.s@mayadata.io> * chore(cpu-cores): Adding cpu-cores in pod-cpu-hog experiments (#257) Signed-off-by: shubhamchaudhary <shubham.chaudhary@mayadata.io> Co-authored-by: Udit Gaurav <35391335+uditgaurav@users.noreply.github.com> * (enhance)httpProbe: add support for optional cert check disable (#259) * (enhance)httpProbe: add support for optional cert check disable Signed-off-by: ksatchit <karthik.s@mayadata.io> * (chore)vendor: update vendor based on chaos operator changes Signed-off-by: ksatchit <karthik.s@mayadata.io> Co-authored-by: Udit Gaurav <35391335+uditgaurav@users.noreply.github.com> Co-authored-by: SamarSidharth <45926857+SamarSidharth@users.noreply.github.com> Co-authored-by: Shubham Chaudhary <shubham.chaudhary@mayadata.io>
1 parent bc2a024 commit e9ea060

File tree

47 files changed

+341
-255
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+341
-255
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Release
33
on:
44
create:
55
tags:
6-
- 'v*'
6+
- '**'
77

88
jobs:
99
lint:
@@ -55,7 +55,7 @@ jobs:
5555

5656
- name: Set Tag
5757
run: |
58-
TAG="${GITHUB_REF#refs/*/v}"
58+
TAG="${GITHUB_REF#refs/*/}"
5959
echo "TAG=${TAG}" >> $GITHUB_ENV
6060
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV
6161

chaoslib/litmus/pod-cpu-hog/lib/pod-cpu-hog.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,16 @@ import (
2424
// StressCPU Uses the REST API to exec into the target container of the target pod
2525
// The function will be constantly increasing the CPU utilisation until it reaches the maximum available or allowed number.
2626
// Using the TOTAL_CHAOS_DURATION we will need to specify for how long this experiment will last
27-
func StressCPU(containerName, podName, namespace, cpuHogCmd string, clients clients.ClientSets) error {
27+
func StressCPU(experimentsDetails *experimentTypes.ExperimentDetails, podName string, clients clients.ClientSets) error {
2828
// It will contains all the pod & container details required for exec command
2929
execCommandDetails := litmusexec.PodDetails{}
30-
command := []string{"/bin/sh", "-c", cpuHogCmd}
31-
litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, containerName, namespace)
30+
command := []string{"/bin/sh", "-c", experimentsDetails.ChaosInjectCmd}
31+
litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, experimentsDetails.TargetContainer, experimentsDetails.AppNS)
3232
_, err := litmusexec.Exec(&execCommandDetails, clients, command)
3333
if err != nil {
3434
return errors.Errorf("Unable to run stress command inside target container, err: %v", err)
3535
}
36+
3637
return nil
3738
}
3839

@@ -85,7 +86,9 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
8586
"Pod": pod.Name,
8687
"CPU CORE": experimentsDetails.CPUcores,
8788
})
88-
go StressCPU(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosInjectCmd, clients)
89+
for i := 0; i < experimentsDetails.CPUcores; i++ {
90+
go StressCPU(experimentsDetails, pod.Name, clients)
91+
}
8992

9093
log.Infof("[Chaos]:Waiting for: %vs", experimentsDetails.ChaosDuration)
9194

@@ -99,7 +102,7 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
99102
select {
100103
case <-signChan:
101104
log.Info("[Chaos]: Killing process started because of terminated signal received")
102-
err := KillStressCPUSerial(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients)
105+
err := KillStressCPUSerial(experimentsDetails, pod.Name, clients)
103106
if err != nil {
104107
klog.V(0).Infof("Error in Kill stress after abortion")
105108
return err
@@ -124,7 +127,7 @@ func InjectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
124127
break loop
125128
}
126129
}
127-
if err := KillStressCPUSerial(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients); err != nil {
130+
if err := KillStressCPUSerial(experimentsDetails, pod.Name, clients); err != nil {
128131
return err
129132
}
130133
}
@@ -150,7 +153,9 @@ func InjectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
150153
"CPU CORE": experimentsDetails.CPUcores,
151154
})
152155

153-
go StressCPU(experimentsDetails.TargetContainer, pod.Name, experimentsDetails.AppNS, experimentsDetails.ChaosInjectCmd, clients)
156+
for i := 0; i < experimentsDetails.CPUcores; i++ {
157+
go StressCPU(experimentsDetails, pod.Name, clients)
158+
}
154159
}
155160

156161
log.Infof("[Chaos]:Waiting for: %vs", experimentsDetails.ChaosDuration)
@@ -165,7 +170,7 @@ loop:
165170
select {
166171
case <-signChan:
167172
log.Info("[Chaos]: Killing process started because of terminated signal received")
168-
err := KillStressCPUParallel(experimentsDetails.TargetContainer, targetPodList, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients)
173+
err := KillStressCPUParallel(experimentsDetails, targetPodList, clients)
169174
if err != nil {
170175
klog.V(0).Infof("Error in Kill stress after abortion")
171176
return err
@@ -190,7 +195,7 @@ loop:
190195
break loop
191196
}
192197
}
193-
if err := KillStressCPUParallel(experimentsDetails.TargetContainer, targetPodList, experimentsDetails.AppNS, experimentsDetails.ChaosKillCmd, clients); err != nil {
198+
if err := KillStressCPUParallel(experimentsDetails, targetPodList, clients); err != nil {
194199
return err
195200
}
196201

@@ -231,13 +236,13 @@ func GetTargetContainer(experimentsDetails *experimentTypes.ExperimentDetails, a
231236

232237
// KillStressCPUSerial function to kill a stress process running inside target container
233238
// Triggered by either timeout of chaos duration or termination of the experiment
234-
func KillStressCPUSerial(containerName, podName, namespace, cpuFreeCmd string, clients clients.ClientSets) error {
239+
func KillStressCPUSerial(experimentsDetails *experimentTypes.ExperimentDetails, podName string, clients clients.ClientSets) error {
235240
// It will contains all the pod & container details required for exec command
236241
execCommandDetails := litmusexec.PodDetails{}
237242

238-
command := []string{"/bin/sh", "-c", cpuFreeCmd}
243+
command := []string{"/bin/sh", "-c", experimentsDetails.ChaosKillCmd}
239244

240-
litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, containerName, namespace)
245+
litmusexec.SetExecCommandAttributes(&execCommandDetails, podName, experimentsDetails.TargetContainer, experimentsDetails.AppNS)
241246
_, err := litmusexec.Exec(&execCommandDetails, clients, command)
242247
if err != nil {
243248
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
248253

249254
// KillStressCPUParallel function to kill all the stress process running inside target container
250255
// Triggered by either timeout of chaos duration or termination of the experiment
251-
func KillStressCPUParallel(containerName string, targetPodList corev1.PodList, namespace, cpuFreeCmd string, clients clients.ClientSets) error {
256+
func KillStressCPUParallel(experimentsDetails *experimentTypes.ExperimentDetails, targetPodList corev1.PodList, clients clients.ClientSets) error {
252257

253258
for _, pod := range targetPodList.Items {
254259

255-
if err := KillStressCPUSerial(containerName, pod.Name, namespace, cpuFreeCmd, clients); err != nil {
260+
if err := KillStressCPUSerial(experimentsDetails, pod.Name, clients); err != nil {
256261
return err
257262
}
258263
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ require (
1212
github.com/imdario/mergo v0.3.9 // indirect
1313
github.com/kr/pretty v0.2.0 // indirect
1414
github.com/kyokomi/emoji v2.2.4+incompatible
15-
github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e
15+
github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8
1616
github.com/mailru/easyjson v0.7.1 // indirect
1717
github.com/openebs/maya v0.0.0-20200411140727-1c81f9e017b0
1818
github.com/pkg/errors v0.9.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9
476476
github.com/lithammer/dedent v1.1.0/go.mod h1:jrXYCQtgg0nJiN+StA2KgR7w6CiQNv9Fd/Z9BP0jIOc=
477477
github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e h1:ubIPSIWT4le0PZZ4MrALdgkiIVmGrz0YzYeWWvSC2a4=
478478
github.com/litmuschaos/chaos-operator v0.0.0-20201210172142-57fddee6734e/go.mod h1:Z2GpYjqXwFd8bx+kv58YEQFxynx1v9PMGCGTQFRVnFQ=
479+
github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8 h1:aEpAyowpCm1lgMoWLcO4Han0yp2WvLuRzKHVKxjvJr0=
480+
github.com/litmuschaos/chaos-operator v0.0.0-20210108143008-188ee98457c8/go.mod h1:Z2GpYjqXwFd8bx+kv58YEQFxynx1v9PMGCGTQFRVnFQ=
479481
github.com/litmuschaos/elves v0.0.0-20201107015738-552d74669e3c/go.mod h1:DsbHGNUq/78NZozWVVI9Q6eBei4I+JjlkkD5aibJ3MQ=
480482
github.com/lpabon/godbc v0.1.1/go.mod h1:Jo9QV0cf3U6jZABgiJ2skINAXb9j8m51r07g4KI92ZA=
481483
github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f h1:sSeNEkJrs+0F9TUau0CgWTTNEwF23HST3Eq0A+QIx+A=

pkg/cassandra/pod-delete/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, cassandraDetails
7171
chaosDetails.Timeout = cassandraDetails.ChaoslibDetail.Timeout
7272
chaosDetails.Delay = cassandraDetails.ChaoslibDetail.Delay
7373
chaosDetails.AppDetail = appDetails
74+
chaosDetails.ProbeImagePullPolicy = cassandraDetails.ChaoslibDetail.LIBImagePullPolicy
7475
}

pkg/generic/disk-fill/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail
6666
chaosDetails.Delay = experimentDetails.Delay
6767
chaosDetails.AppDetail = appDetails
6868
chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain")
69+
chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy
6970
}

pkg/generic/kubelet-service-kill/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail
5353
chaosDetails.Timeout = experimentDetails.Timeout
5454
chaosDetails.Delay = experimentDetails.Delay
5555
chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain")
56+
chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy
5657
}

pkg/generic/network-chaos/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail
7575
chaosDetails.ChaosDuration = experimentDetails.ChaosDuration
7676
chaosDetails.AppDetail = appDetails
7777
chaosDetails.JobCleanupPolicy = Getenv("JOB_CLEANUP_POLICY", "retain")
78+
chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy
7879
}

pkg/generic/network-latency/environment/environment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,5 @@ func InitialiseChaosVariables(chaosDetails *types.ChaosDetails, experimentDetail
104104
chaosDetails.InstanceID = experimentDetails.InstanceID
105105
chaosDetails.Timeout = experimentDetails.Timeout
106106
chaosDetails.Delay = experimentDetails.Delay
107+
chaosDetails.ProbeImagePullPolicy = experimentDetails.LIBImagePullPolicy
107108
}

pkg/generic/network-latency/types/types.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,27 @@ import (
77

88
// ExperimentDetails is for collecting all the experiment-related details
99
type ExperimentDetails struct {
10-
ExperimentName string
11-
EngineName string
12-
ChaosDuration int
13-
ChaosInterval int
14-
RampTime int
15-
ChaosLib string
16-
ChaosServiceAccount string
17-
AppNS string
18-
AppLabel string
19-
AppKind string
20-
ChaosUID clientTypes.UID
21-
AuxiliaryAppInfo string
22-
InstanceID string
23-
ChaosNamespace string
24-
ChaosPodName string
25-
Latency float64
26-
Jitter float64
27-
ChaosNode string
28-
Timeout int
29-
Delay int
10+
ExperimentName string
11+
EngineName string
12+
ChaosDuration int
13+
ChaosInterval int
14+
RampTime int
15+
ChaosLib string
16+
ChaosServiceAccount string
17+
AppNS string
18+
AppLabel string
19+
AppKind string
20+
ChaosUID clientTypes.UID
21+
AuxiliaryAppInfo string
22+
InstanceID string
23+
ChaosNamespace string
24+
ChaosPodName string
25+
Latency float64
26+
Jitter float64
27+
ChaosNode string
28+
Timeout int
29+
Delay int
30+
LIBImagePullPolicy string
3031
}
3132

3233
// Definition is the chaos experiment definition coming from a user input file.

0 commit comments

Comments
 (0)