Skip to content

Commit 541a396

Browse files
fix write to io.max and cli flag name
1 parent 4a3a0ae commit 541a396

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

cmd/cgroup2ctl/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func main() {
1313
// Define command-line flags
1414
cgroupPath := flag.String("cgroup", "", "Path to cgroup directory")
15-
ioConfigFile := flag.String("config", "", "Path to JSON configuration file for IO limits")
15+
ioConfigFile := flag.String("io-config", "", "Path to JSON configuration file for IO limits")
1616
memoryLimit := flag.String("memory", "", "Memory limit (e.g. 1G, 500M)")
1717
swapLimit := flag.String("swap", "", "Swap limit (e.g. 2G, 1G)")
1818

pkg/cgroup2/io/io.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package io
33

44
import (
55
"fmt"
6-
"path/filepath"
76

87
"github.com/puzl-cloud/go-cgroup2/pkg/common"
98
)
@@ -73,16 +72,8 @@ func SetDeviceIOLimits(cgroupPath, deviceNumbers string, readBps, writeBps, read
7372
ioMaxValue := fmt.Sprintf("%s rbps=%s wbps=%s riops=%s wiops=%s",
7473
deviceNumbers, rbpsStr, wbpsStr, riopsStr, wiopsStr)
7574

76-
// Get the full path to io.max
77-
ioMaxPath := filepath.Join(cgroupPath, IOMaxFile)
78-
7975
// Write the value to io.max
80-
err := common.WriteValueToFile(ioMaxPath, IOMaxFile, ioMaxValue)
81-
if err != nil {
82-
return fmt.Errorf("failed to write IO limits to %s: %w", ioMaxPath, err)
83-
}
84-
85-
return nil
76+
return common.WriteValueToFile(cgroupPath, IOMaxFile, ioMaxValue)
8677
}
8778

8879
// SetIOLimitsFromJsonString applies IO limits from a JSON

0 commit comments

Comments
 (0)