Skip to content

Commit

Permalink
chore(stress): Fix the stress faults (#723)
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Chaudhary <[email protected]>
  • Loading branch information
ispeakc0de authored Nov 20, 2024
1 parent 3ef23b0 commit 7e08c69
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions chaoslib/litmus/stress-chaos/helper/stress-helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func prepareStressChaos(experimentsDetails *experimentTypes.ExperimentDetails, c
done := make(chan error, 1)

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

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

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

0 comments on commit 7e08c69

Please sign in to comment.