Skip to content

Commit 7e08c69

Browse files
authored
chore(stress): Fix the stress faults (#723)
Signed-off-by: Shubham Chaudhary <[email protected]>
1 parent 3ef23b0 commit 7e08c69

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

chaoslib/litmus/stress-chaos/helper/stress-helper.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func prepareStressChaos(experimentsDetails *experimentTypes.ExperimentDetails, c
146146
done := make(chan error, 1)
147147

148148
for index, t := range targets {
149-
targets[index].Cmd, err = injectChaos(t, stressors)
149+
targets[index].Cmd, err = injectChaos(t, stressors, experimentsDetails.StressType)
150150
if err != nil {
151151
return stacktrace.Propagate(err, "could not inject chaos")
152152
}
@@ -531,8 +531,13 @@ func addProcessToCgroup(pid int, control interface{}) error {
531531
return cgroup1.Add(cgroups.Process{Pid: pid})
532532
}
533533

534-
func injectChaos(t targetDetails, stressors string) (*exec.Cmd, error) {
535-
stressCommand := "pause nsutil -t " + strconv.Itoa(t.Pid) + " -p -m -- " + stressors
534+
func injectChaos(t targetDetails, stressors, stressType string) (*exec.Cmd, error) {
535+
stressCommand := fmt.Sprintf("pause nsutil -t %v -p -- %v", strconv.Itoa(t.Pid), stressors)
536+
// for io stress,we need to enter into mount ns of the target container
537+
// enabling it by passing -m flag
538+
if stressType == "pod-io-stress" {
539+
stressCommand = fmt.Sprintf("pause nsutil -t %v -p -m -- %v", strconv.Itoa(t.Pid), stressors)
540+
}
536541
log.Infof("[Info]: starting process: %v", stressCommand)
537542

538543
// launch the stress-ng process on the target container in paused mode

0 commit comments

Comments
 (0)