Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroups: Fix race to load cgroup.hostRoot option #27561

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/cgroups/manager/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

var (
cgroupRoot = cgroups.GetCgroupRoot()
// example default cgroup path in kubernetes environments
// /kubepods/burstable/pod1858680e-b044-4fd5-9dd4-f137e30e2180/e275d1a37782ab30008aa3ae6666cccefe53b3a14a2ab5a8dc459939107c8c0
defaultCgroupBasePath = "/kubepods"
Expand Down Expand Up @@ -164,7 +163,7 @@ func getSystemdContainerPathCommon(subPaths []string, podId string, containerId
}

func validateCgroupPath(path string) (string, error) {
fullPath := cgroupRoot + path
fullPath := cgroups.GetCgroupRoot() + path

if _, err := fschecker.Stat(fullPath); err == nil {
return fullPath, nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/cgroups/manager/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

. "github.com/cilium/checkmate"

"github.com/cilium/cilium/pkg/cgroups"
"github.com/cilium/cilium/pkg/checker"
v1 "github.com/cilium/cilium/pkg/k8s/slim/k8s/api/core/v1"
)
Expand All @@ -30,6 +31,7 @@ var (
fsMockSystemdNested = fsMock{
getFullPath(nestedSystemdCgroupBasePath): struct{}{},
}
cgroupRoot = cgroups.GetCgroupRoot()
cDefaultPath = cgroupRoot + "/kubepods/burstable/pod1858680e-b044-4fd5-9dd4-f137e30e2180/" + c1Id
cDefaultGuaranteedPath = cgroupRoot + "/kubepods/pod1858680e-b044-4fd5-9dd4-f137e30e2180/" + c1Id
cSystemdPath = cgroupRoot + "/kubepods.slice/kubepods-burstable.slice/kubepods-burstable-pod1858680e_b044_4fd5_9dd4_f137e30e2180.slice/" + "cri-containerd-" + c1Id + ".scope"
Expand Down