mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-27 16:50:23 +00:00
util: getCgroupPidsFile produces striped path when extra : present
This commit uses `string.SplitN` instead of `string.Split`.
The path for pids.max has extra `:` symbols in it due to which
getCgroupPidsFile() splits the string into 5 tokens instead of
3 leading to loss of part of the path.
As a result, the below error is reported:
`Failed to get the PID limit, can not reconfigure: open
/sys/fs/cgroup/pids/system.slice/containerd.service/
kubepods-besteffort-pod183b9d14_aed1_4b66_a696_da0c738bc012.slice/pids.max:
no such file or directory`
SplitN takes an argument n and splits the string
accordingly which helps us to get the desired
file path.
Fixes: #2337
Co-authored-by: Yati Padia <ypadia@redhat.com>
Signed-off-by: Yati Padia <ypadia@redhat.com>
(cherry picked from commit 16ec97d8f7
)
This commit is contained in:
parent
966841cafc
commit
82fd1e5248
@ -47,7 +47,7 @@ func getCgroupPidsFile() (string, error) {
|
||||
scanner := bufio.NewScanner(cgroup)
|
||||
var slice string
|
||||
for scanner.Scan() {
|
||||
parts := strings.Split(scanner.Text(), ":")
|
||||
parts := strings.SplitN(scanner.Text(), ":", 3)
|
||||
if parts == nil || len(parts) < 3 {
|
||||
continue
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user