cgroups: Fix "." parent cgroup special case

ef642fe890 added a special case to avoid
moving cgroups that are on the "default" slice in case of deletion.

However, this special check should be done in the Parent() method
instead, which ensures that the default resource controller ID is
returned, instead of ".".

Fixes: #11599

Signed-off-by: Fabiano Fidêncio <fidencio@northflank.com>
This commit is contained in:
Fabiano Fidêncio 2025-08-25 11:43:16 +02:00 committed by Fabiano Fidêncio
parent 63f6dcdeb9
commit 08d2ba1969
2 changed files with 3 additions and 5 deletions

View File

@ -31,7 +31,7 @@ const (
)
func RenameCgroupPath(path string) (string, error) {
if path == "" {
if path == "" || path == "." {
path = DefaultResourceControllerID
}

View File

@ -2546,10 +2546,8 @@ func (s *Sandbox) resourceControllerDelete() error {
}
resCtrlParent := sandboxController.Parent()
if resCtrlParent != "." {
if err := sandboxController.MoveTo(resCtrlParent); err != nil {
return err
}
if err := sandboxController.MoveTo(resCtrlParent); err != nil {
return err
}
if err := sandboxController.Delete(); err != nil {