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

Support cgroup namespaces for cgroup v1 #349

Merged
merged 5 commits into from
Oct 2, 2021
Merged

Conversation

Furisto
Copy link
Collaborator

@Furisto Furisto commented Sep 30, 2021

This adds support for namespacing v1 control cgroups.

Tasks still open

  • Emulate namespacing behavior even if no cgroup namespace is specified
  • Add support for cgroup v2

I will add this in another PR.

@codecov-commenter
Copy link

codecov-commenter commented Sep 30, 2021

Codecov Report

Merging #349 (541c1a0) into main (c206d88) will decrease coverage by 1.38%.
The diff coverage is 30.87%.

@@            Coverage Diff             @@
##             main     #349      +/-   ##
==========================================
- Coverage   70.45%   69.07%   -1.39%     
==========================================
  Files          46       47       +1     
  Lines        6844     7029     +185     
==========================================
+ Hits         4822     4855      +33     
- Misses       2022     2174     +152     

@utam0k
Copy link
Member

utam0k commented Oct 1, 2021

Perhaps this is a good feature. Can I ask you to open the issue about this and describe more details?

@Furisto
Copy link
Collaborator Author

Furisto commented Oct 1, 2021

#332 is the feature 😉 . In order to support cgroup mounts we can use cgroup namespaces . Once a cgroup namespace is entered, the cgroup the process is currently in will become the root of the subsystem hierarchy in the namespace. This means that the container is not able to see the parent cgroups. That is what the cgroup mount is about, an own view of the cgroup hierarchy for the container.

To make this more descriptive, without a cgroup mount the container will see:
/sys
 /fs
  /cgroup
   /blkio
    /sub1
     /sub2 <- cgroup the container is in

With cgroup mount
/sys
 /fs
  /cgroup
   /blkio <- this is actually sub2

@utam0k
Copy link
Member

utam0k commented Oct 2, 2021

@Furisto Thanks! That's a great description. I understand.

@@ -37,6 +37,25 @@ impl Display for ControllerType {
}
}

impl AsRef<str> for ControllerType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -187,11 +187,11 @@ pub fn container_init(
&& ns_type != CloneFlags::CLONE_NEWPID
&& ns_type != CloneFlags::CLONE_NEWNS
})
.with_context(|| "Failed to apply namespaces")?;
.with_context(|| "failed to apply namespaces")?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

// this needs to be done before we create the init process, so that the init
// process will already be captured by the cgroup
if args.rootless.is_none() {
apply_cgroups(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I ask you to update docs/.drawio.svg using vscode-drawing.

@Furisto
Copy link
Collaborator Author

Furisto commented Oct 2, 2021

@utam0k Done

Copy link
Member

@utam0k utam0k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@utam0k utam0k merged commit 4999a90 into youki-dev:main Oct 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants