Skip to content

cgroupv1 removal nits#2506

Merged
mrunalp merged 4 commits intoopencontainers:masterfrom
kolyshkin:cgroup-fixes
Aug 18, 2020
Merged

cgroupv1 removal nits#2506
mrunalp merged 4 commits intoopencontainers:masterfrom
kolyshkin:cgroup-fixes

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

This set is a followup to #2503. It does the following:

  • moves cleaning of paths map to RemovePaths so its callers don't have to;
  • adds cgroups.RemovePath (code move from fs2.removeCgroupPath);
  • optimizes cgroups.RemovePaths() by reusing RemovePath instead of os.RemoveAll;
  • adds a test case of cgroupv1 + sub-cgroups removal.

Please see individual commits for details.

kolyshkin added 3 commits July 6, 2020 17:54
RemovePaths() deletes elements from the paths map for paths that has
been successfully removed.

Although, it does not empty the map itself (which is needed that AFAIK
Go garbage collector does not shrink the map), but all its callers do.

Move this operation from callers to RemovePaths.

No functional change, except the old map should be garbage collected now.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This is to be used by RemovePaths.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Using os.RemoveAll has the following two issues:

 1. it tries to remove all files, which does not make sense for cgroups;
 2. it tries rm(2) which fails to directories, and then rmdir(2).

Let's reuse our RemovePath instead, and add warnings and errors logging.

PS I am somewhat hesitant to remove the weird checking my means of stat,
as it might break something. Unfortunately, neither commit 6feb7bd
nor the PR it contains [1] do not explain what kind of weird errors were
seen from os.RemoveAll. Most probably our code won't return any bogus
errors, but let's keep the old code to be on the safe side.

[1] docker-archive/libcontainer#308

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Copy Markdown
Contributor Author

@giuseppe @mrunalp @AkihiroSuda PTAL

@cyphar
Copy link
Copy Markdown
Member

cyphar commented Jul 7, 2020

New integration test fails on centos:

not ok 26 runc delete --force in cgroupv1 with subcgroups
# (in test file tests/integration/delete.bats, line 66)
#   `[ "$status" -eq 0 ]' failed
# runc list (status=0):
# ID          PID         STATUS      BUNDLE      CREATED     OWNER
# runc spec (status=0):
# 
# runc run -d --console-socket /tmp/console.sock test_busybox (status=1):
# time="2020-07-07T01:11:20Z" level=error msg="cgroup namespaces aren't enabled in the kernel"
# runc list (status=0):
# ID          PID         STATUS      BUNDLE      CREATED     OWNER

This is similar to what we did before for v2.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Copy Markdown
Contributor Author

Amended the test case to require cgroupns (testing without it is kinda cumbersome)

@AkihiroSuda
Copy link
Copy Markdown
Member

@mrunalp PTAL

@AkihiroSuda
Copy link
Copy Markdown
Member

@mrunalp @cyphar PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants