@@ -111,7 +111,7 @@ func prepareStressChaos(experimentsDetails *experimentTypes.ExperimentDetails, c
111
111
}
112
112
113
113
var (
114
- targets []targetDetails
114
+ targets []targetDetails
115
115
)
116
116
117
117
for _ , t := range targetList .Target {
@@ -504,7 +504,7 @@ func abortWatcher(targets []targetDetails, resultName, chaosNS string) {
504
504
func getCGroupManager (t targetDetails ) (interface {}, error , string ) {
505
505
if cgroups .Mode () == cgroups .Unified {
506
506
groupPath := ""
507
- output , err := exec .Command ("bash" , "-c" , fmt .Sprintf ("nsenter -t 1 -C -m -- cat /proc/%v/cgroup" , t .Pids [ index ] )).CombinedOutput ()
507
+ output , err := exec .Command ("bash" , "-c" , fmt .Sprintf ("nsenter -t 1 -C -m -- cat /proc/%v/cgroup" , t .Pid )).CombinedOutput ()
508
508
if err != nil {
509
509
return nil , errors .Errorf ("Error in getting groupPath,%s" , string (output )), ""
510
510
}
@@ -518,7 +518,7 @@ func getCGroupManager(t targetDetails) (interface{}, error, string) {
518
518
519
519
log .Infof ("group path: %s" , groupPath )
520
520
521
- cgroup2 , err := cgroupsv2 .LoadManager ("/sys/fs/cgroup" , string ( groupPath ) )
521
+ cgroup2 , err := cgroupsv2 .LoadManager ("/sys/fs/cgroup" , groupPath )
522
522
if err != nil {
523
523
return nil , errors .Errorf ("Error loading cgroup v2 manager, %v" , err ), ""
524
524
}
@@ -541,7 +541,7 @@ func getCGroupManager(t targetDetails) (interface{}, error, string) {
541
541
// By default it will add to v1 cgroup
542
542
func addProcessToCgroup (pid int , control interface {}, groupPath string ) error {
543
543
if cgroups .Mode () == cgroups .Unified {
544
- args := []string {"-t" , "1" , "-C" , "--" , "sudo" , "sh" , "-c" , fmt .Sprintf ("echo %d >> /sys/fs/cgroup%s/cgroup.procs" , pid , strings .ReplaceAll (groupPath , "\n " , "" ))}
544
+ args := []string {"-t" , "1" , "-C" , "--" , "sudo" , "sh" , "-c" , fmt .Sprintf ("echo %d >> /sys/fs/cgroup%s/cgroup.procs" , pid , strings .ReplaceAll (groupPath , "\n " , "" ))}
545
545
output , err := exec .Command ("nsenter" , args ... ).CombinedOutput ()
546
546
if err != nil {
547
547
return cerrors.Error {
@@ -555,7 +555,6 @@ func addProcessToCgroup(pid int, control interface{}, groupPath string) error {
555
555
return cgroup1 .Add (cgroups.Process {Pid : pid })
556
556
}
557
557
558
-
559
558
func injectChaos (t targetDetails , stressors , stressType string ) (* exec.Cmd , error ) {
560
559
stressCommand := fmt .Sprintf ("pause nsutil -t %v -p -- %v" , strconv .Itoa (t .Pid ), stressors )
561
560
// for io stress,we need to enter into mount ns of the target container
@@ -605,5 +604,5 @@ type targetDetails struct {
605
604
CGroupManager interface {}
606
605
Cmd * exec.Cmd
607
606
Source string
608
- GroupPath string
607
+ GroupPath string
609
608
}
0 commit comments