Skip to content

Commit 6ad9db0

Browse files
uditgauravneelanjan00Akash ShrivastavaoumkaleShubham Chaudhary
authored
[Cherry-pick for 2.0.0] (#435)
* Auxiliary Application Check for node-memory-hog Experiment and Multiple Target Node Functionality Fix for three Node-Level Experiments (#424) * Fixed multiple node selection functionality in nodes.go Signed-off-by: neelanjan00 <[email protected]> * Added Auxiliary Application Status Check to node-memory-hog experiment Signed-off-by: neelanjan00 <[email protected]> * Pod experiment fixes (#429) * Fixed issue with pod affected percentage > 100 Signed-off-by: Akash Shrivastava <[email protected]> * resolve conflict Signed-off-by: udit <[email protected]> * fixing bugs (#418) Signed-off-by: Oum Kale <[email protected]> Co-authored-by: Shubham Chaudhary <[email protected]> * feat(helper-status): fix helper status timeout when helper pod failed (#421) Signed-off-by: shubham chaudhary <[email protected]> * resolve conflict Signed-off-by: udit <[email protected]> * feat(exec-chaos): handle the abort signal (#425) Signed-off-by: shubham chaudhary <[email protected]> * feat(target-pods: validating target pods env (#430) Signed-off-by: shubham chaudhary <[email protected]> * feat(experiment): derive parent name in pod-delete only (#434) Signed-off-by: shubham chaudhary <[email protected]> Co-authored-by: Neelanjan Manna <[email protected]> Co-authored-by: Akash Shrivastava <[email protected]> Co-authored-by: OUM NIVRATHI KALE <[email protected]> Co-authored-by: Shubham Chaudhary <[email protected]>
1 parent f67b15d commit 6ad9db0

File tree

64 files changed

+610
-422
lines changed

Some content is hidden

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

64 files changed

+610
-422
lines changed

.github/workflows/build.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ jobs:
2525
sudo apt-get update && sudo apt-get install golint
2626
make gotasks
2727
28+
- name: gofmt check
29+
run: |
30+
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
31+
then
32+
echo "The following files were found to be not go formatted:"
33+
gofmt -s -l .
34+
exit 1
35+
fi
36+
37+
- name: golangci-lint
38+
uses: reviewdog/action-golangci-lint@v1
39+
2840
build:
2941
needs: pre-checks
3042
runs-on: ubuntu-latest

.github/workflows/push.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@ jobs:
2323
sudo apt-get update && sudo apt-get install golint
2424
make gotasks
2525
26+
- name: gofmt check
27+
run: |
28+
if [ "$(gofmt -s -l . | wc -l)" -ne 0 ]
29+
then
30+
echo "The following files were found to be not go formatted:"
31+
gofmt -s -l .
32+
exit 1
33+
fi
34+
35+
- name: golangci-lint
36+
uses: reviewdog/action-golangci-lint@v1
37+
2638
push:
2739
needs: pre-checks
2840
runs-on: ubuntu-latest

chaoslib/litmus/docker-service-kill/lib/docker-service-kill.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,6 @@ func PrepareDockerServiceKill(experimentsDetails *experimentTypes.ExperimentDeta
9191
return errors.Errorf("helper pod failed, err: %v", err)
9292
}
9393

94-
// Checking the status of target nodes
95-
log.Info("[Status]: Getting the status of target nodes")
96-
if err = status.CheckNodeStatus(experimentsDetails.TargetNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
97-
common.DeleteHelperPodBasedOnJobCleanupPolicy(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, chaosDetails, clients)
98-
log.Warnf("Target nodes are not in the ready state, you may need to manually recover the node, err: %v", err)
99-
}
100-
10194
//Deleting the helper pod
10295
log.Info("[Cleanup]: Deleting the helper pod")
10396
if err = common.DeletePod(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {

chaoslib/litmus/kafka-broker-pod-failure/lib/pod-delete.go

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/litmuschaos/litmus-go/pkg/probe"
1313
"github.com/litmuschaos/litmus-go/pkg/status"
1414
"github.com/litmuschaos/litmus-go/pkg/types"
15+
"github.com/litmuschaos/litmus-go/pkg/utils/annotation"
1516
"github.com/litmuschaos/litmus-go/pkg/utils/common"
1617
"github.com/pkg/errors"
1718
"github.com/sirupsen/logrus"
@@ -74,8 +75,18 @@ func injectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
7475
return err
7576
}
7677

77-
for _, target := range chaosDetails.ParentsResources {
78-
common.SetTargets(target, "targeted", chaosDetails.AppDetail.Kind, chaosDetails)
78+
// deriving the parent name of the target resources
79+
if chaosDetails.AppDetail.Kind != "" {
80+
for _, pod := range targetPodList.Items {
81+
parentName, err := annotation.GetParentName(clients, pod, chaosDetails)
82+
if err != nil {
83+
return err
84+
}
85+
common.SetParentName(parentName, chaosDetails)
86+
}
87+
for _, target := range chaosDetails.ParentsResources {
88+
common.SetTargets(target, "targeted", chaosDetails.AppDetail.Kind, chaosDetails)
89+
}
7990
}
8091

8192
if experimentsDetails.ChaoslibDetail.EngineName != "" {
@@ -152,8 +163,18 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
152163
return err
153164
}
154165

155-
for _, target := range chaosDetails.ParentsResources {
156-
common.SetTargets(target, "targeted", chaosDetails.AppDetail.Kind, chaosDetails)
166+
// deriving the parent name of the target resources
167+
if chaosDetails.AppDetail.Kind != "" {
168+
for _, pod := range targetPodList.Items {
169+
parentName, err := annotation.GetParentName(clients, pod, chaosDetails)
170+
if err != nil {
171+
return err
172+
}
173+
common.SetParentName(parentName, chaosDetails)
174+
}
175+
for _, target := range chaosDetails.ParentsResources {
176+
common.SetTargets(target, "targeted", chaosDetails.AppDetail.Kind, chaosDetails)
177+
}
157178
}
158179

159180
if experimentsDetails.ChaoslibDetail.EngineName != "" {

chaoslib/litmus/kubelet-service-kill/lib/kubelet-service-kill.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,6 @@ func PrepareKubeletKill(experimentsDetails *experimentTypes.ExperimentDetails, c
9393
return errors.Errorf("helper pod failed, err: %v", err)
9494
}
9595

96-
// Checking the status of target nodes
97-
log.Info("[Status]: Getting the status of target nodes")
98-
if err = status.CheckNodeStatus(experimentsDetails.TargetNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
99-
common.DeleteHelperPodBasedOnJobCleanupPolicy(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, chaosDetails, clients)
100-
log.Warnf("Target nodes are not in the ready state, you may need to manually recover the node, err: %v", err)
101-
}
102-
10396
//Deleting the helper pod
10497
log.Info("[Cleanup]: Deleting the helper pod")
10598
if err = common.DeletePod(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,6 @@ func injectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
123123
return errors.Errorf("helper pod failed due to, err: %v", err)
124124
}
125125

126-
// Checking the status of target nodes
127-
log.Info("[Status]: Getting the status of target nodes")
128-
if err = status.CheckNodeStatus(appNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
129-
common.DeleteHelperPodBasedOnJobCleanupPolicy(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, chaosDetails, clients)
130-
log.Warnf("Target nodes are not in the ready state, you may need to manually recover the node, err: %v", err)
131-
}
132-
133126
//Deleting the helper pod
134127
log.Info("[Cleanup]: Deleting the helper pod")
135128
if err = common.DeletePod(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {
@@ -201,16 +194,6 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
201194
return errors.Errorf("helper pod failed due to, err: %v", err)
202195
}
203196

204-
for _, appNode := range targetNodeList {
205-
206-
// Checking the status of application node
207-
log.Info("[Status]: Getting the status of application node")
208-
if err = status.CheckNodeStatus(appNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
209-
common.DeleteAllHelperPodBasedOnJobCleanupPolicy(appLabel, chaosDetails, clients)
210-
log.Warn("Application node is not in the ready state, you may need to manually recover the node")
211-
}
212-
}
213-
214197
//Deleting the helper pod
215198
log.Info("[Cleanup]: Deleting the helper pod")
216199
if err = common.DeleteAllPod(appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {

chaoslib/litmus/node-drain/lib/node-drain.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ func PrepareNodeDrain(experimentsDetails *experimentTypes.ExperimentDetails, cli
100100
return err
101101
}
102102

103-
// Checking the status of target nodes
104-
log.Info("[Status]: Getting the status of target nodes")
105-
if err = status.CheckNodeStatus(experimentsDetails.TargetNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
106-
log.Warnf("Target nodes are not in the ready state, you may need to manually recover the node, err: %v", err)
107-
}
108-
109103
//Waiting for the ramp time after chaos injection
110104
if experimentsDetails.RampTime != 0 {
111105
log.Infof("[Ramp]: Waiting for the %vs ramp time after injecting chaos", experimentsDetails.RampTime)

chaoslib/litmus/node-io-stress/lib/node-io-stress.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,6 @@ func injectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
115115
return errors.Errorf("helper pod failed due to, err: %v", err)
116116
}
117117

118-
// Checking the status of target nodes
119-
log.Info("[Status]: Getting the status of target nodes")
120-
if err = status.CheckNodeStatus(appNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
121-
common.DeleteHelperPodBasedOnJobCleanupPolicy(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, chaosDetails, clients)
122-
log.Warnf("Target nodes are not in the ready state, you may need to manually recover the node, err: %v", err)
123-
}
124-
125118
//Deleting the helper pod
126119
log.Info("[Cleanup]: Deleting the helper pod")
127120
if err = common.DeletePod(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {
@@ -188,16 +181,6 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
188181
return errors.Errorf("helper pod failed due to, err: %v", err)
189182
}
190183

191-
for _, appNode := range targetNodeList {
192-
193-
// Checking the status of application node
194-
log.Info("[Status]: Getting the status of application node")
195-
if err = status.CheckNodeStatus(appNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
196-
common.DeleteAllHelperPodBasedOnJobCleanupPolicy(appLabel, chaosDetails, clients)
197-
log.Warn("Application node is not in the ready state, you may need to manually recover the node")
198-
}
199-
}
200-
201184
//Deleting the helper pod
202185
log.Info("[Cleanup]: Deleting the helper pod")
203186
if err = common.DeleteAllPod(appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {

chaoslib/litmus/node-memory-hog/lib/node-memory-hog.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,6 @@ func injectChaosInSerialMode(experimentsDetails *experimentTypes.ExperimentDetai
131131
return errors.Errorf("helper pod status is %v", podStatus)
132132
}
133133

134-
// Checking the status of target nodes
135-
log.Info("[Status]: Getting the status of target nodes")
136-
if err = status.CheckNodeStatus(appNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
137-
common.DeleteHelperPodBasedOnJobCleanupPolicy(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, chaosDetails, clients)
138-
log.Warnf("Target nodes are not in the ready state, you may need to manually recover the node, err: %v", err)
139-
}
140-
141134
//Deleting the helper pod
142135
log.Info("[Cleanup]: Deleting the helper pod")
143136
if err = common.DeletePod(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {
@@ -217,16 +210,6 @@ func injectChaosInParallelMode(experimentsDetails *experimentTypes.ExperimentDet
217210
return errors.Errorf("helper pod status is %v", podStatus)
218211
}
219212

220-
for _, appNode := range targetNodeList {
221-
222-
// Checking the status of application node
223-
log.Info("[Status]: Getting the status of application node")
224-
if err = status.CheckNodeStatus(appNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
225-
common.DeleteAllHelperPodBasedOnJobCleanupPolicy(appLabel, chaosDetails, clients)
226-
log.Warn("Application node is not in the ready state, you may need to manually recover the node")
227-
}
228-
}
229-
230213
//Deleting the helper pod
231214
log.Info("[Cleanup]: Deleting the helper pod")
232215
if err = common.DeleteAllPod(appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {

chaoslib/litmus/node-restart/lib/node-restart.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ func PrepareNodeRestart(experimentsDetails *experimentTypes.ExperimentDetails, c
5858
"Target Node IP": experimentsDetails.TargetNodeIP,
5959
})
6060

61-
// Checking the status of target node
62-
log.Info("[Status]: Getting the status of target node")
63-
if err = status.CheckNodeStatus(experimentsDetails.TargetNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
64-
return errors.Errorf("target node is not in ready state, err: %v", err)
65-
}
66-
6761
experimentsDetails.RunID = common.GetRunID()
6862
appLabel := "name=" + experimentsDetails.ExperimentName + "-helper-" + experimentsDetails.RunID
6963

@@ -113,13 +107,6 @@ func PrepareNodeRestart(experimentsDetails *experimentTypes.ExperimentDetails, c
113107
return errors.Errorf("helper pod failed due to, err: %v", err)
114108
}
115109

116-
// Checking the status of application node
117-
log.Info("[Status]: Getting the status of application node")
118-
if err = status.CheckNodeStatus(experimentsDetails.TargetNode, experimentsDetails.Timeout, experimentsDetails.Delay, clients); err != nil {
119-
common.DeleteHelperPodBasedOnJobCleanupPolicy(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, chaosDetails, clients)
120-
log.Warnf("Application node is not in the ready state, you may need to manually recover the node, err: %v", err)
121-
}
122-
123110
//Deleting the helper pod
124111
log.Info("[Cleanup]: Deleting the helper pod")
125112
if err = common.DeletePod(experimentsDetails.ExperimentName+"-helper-"+experimentsDetails.RunID, appLabel, experimentsDetails.ChaosNamespace, chaosDetails.Timeout, chaosDetails.Delay, clients); err != nil {

0 commit comments

Comments
 (0)