Skip to content

Commit

Permalink
(chore): fix the go fmt of the files (#734)
Browse files Browse the repository at this point in the history
Signed-off-by: Shubham Chaudhary <[email protected]>
  • Loading branch information
ispeakc0de authored Jan 17, 2025
1 parent 34a62d8 commit caae228
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions chaoslib/litmus/stress-chaos/helper/stress-helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func prepareStressChaos(experimentsDetails *experimentTypes.ExperimentDetails, c
}

var (
targets []targetDetails
targets []targetDetails
)

for _, t := range targetList.Target {
Expand Down Expand Up @@ -504,7 +504,7 @@ func abortWatcher(targets []targetDetails, resultName, chaosNS string) {
func getCGroupManager(t targetDetails) (interface{}, error, string) {
if cgroups.Mode() == cgroups.Unified {
groupPath := ""
output, err := exec.Command("bash", "-c", fmt.Sprintf("nsenter -t 1 -C -m -- cat /proc/%v/cgroup", t.Pids[index])).CombinedOutput()
output, err := exec.Command("bash", "-c", fmt.Sprintf("nsenter -t 1 -C -m -- cat /proc/%v/cgroup", t.Pid)).CombinedOutput()
if err != nil {
return nil, errors.Errorf("Error in getting groupPath,%s", string(output)), ""
}
Expand All @@ -518,7 +518,7 @@ func getCGroupManager(t targetDetails) (interface{}, error, string) {

log.Infof("group path: %s", groupPath)

cgroup2, err := cgroupsv2.LoadManager("/sys/fs/cgroup", string(groupPath))
cgroup2, err := cgroupsv2.LoadManager("/sys/fs/cgroup", groupPath)
if err != nil {
return nil, errors.Errorf("Error loading cgroup v2 manager, %v", err), ""
}
Expand All @@ -541,7 +541,7 @@ func getCGroupManager(t targetDetails) (interface{}, error, string) {
// By default it will add to v1 cgroup
func addProcessToCgroup(pid int, control interface{}, groupPath string) error {
if cgroups.Mode() == cgroups.Unified {
args := []string{"-t", "1", "-C", "--", "sudo", "sh", "-c", fmt.Sprintf("echo %d >> /sys/fs/cgroup%s/cgroup.procs", pid, strings.ReplaceAll(groupPath, "\n", ""))}
args := []string{"-t", "1", "-C", "--", "sudo", "sh", "-c", fmt.Sprintf("echo %d >> /sys/fs/cgroup%s/cgroup.procs", pid, strings.ReplaceAll(groupPath, "\n", ""))}
output, err := exec.Command("nsenter", args...).CombinedOutput()
if err != nil {
return cerrors.Error{
Expand All @@ -555,7 +555,6 @@ func addProcessToCgroup(pid int, control interface{}, groupPath string) error {
return cgroup1.Add(cgroups.Process{Pid: pid})
}


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
Expand Down Expand Up @@ -605,5 +604,5 @@ type targetDetails struct {
CGroupManager interface{}
Cmd *exec.Cmd
Source string
GroupPath string
GroupPath string
}

0 comments on commit caae228

Please sign in to comment.