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

cgroup: add support for unified cgroup v2 #459

Merged
merged 3 commits into from
Aug 21, 2020

Conversation

giuseppe
Copy link
Member

add support for: opencontainers/runtime-spec#1040

Signed-off-by: Giuseppe Scrivano [email protected]

@giuseppe
Copy link
Member Author

@mrunalp PTAL

@mrunalp
Copy link

mrunalp commented Aug 17, 2020

Reviewing..

return crun_make_error (err, 0, "key `%s` must be a file name without any slash", resources->unified->keys[i]);

len = strlen (resources->unified->values[i]);
ret = write_file_at (cgroup_dirfd, resources->unified->keys[i], resources->unified->values[i], len, err);
Copy link

Choose a reason for hiding this comment

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

How do we handle validation for the values?

Copy link

Choose a reason for hiding this comment

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

We could punt to the kernel entirely but we should ensure we are returning a clear error that we failed writing to unified cgroup value and advise user to check the kernel documentation for the accepted values for a setting.

Copy link
Member Author

Choose a reason for hiding this comment

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

agree, I've added some logic to return more useful error messages when the controller is not present

@mrunalp
Copy link

mrunalp commented Aug 17, 2020

Could we add any tests for this?

{
size_t len;

if (strchr (resources->unified->keys[i], '/'))
Copy link

Choose a reason for hiding this comment

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

We should map the keys to the known controllers as well and fail if it isn't known to the runtime.

Copy link
Member Author

Choose a reason for hiding this comment

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

why would we need to do that? I think we can just write to the specified file (and that was one of the reasons for using the map in the OCI spec PR), since the key is the file name itself. In any case the OCI runtime is not doing any handling of this information

giuseppe and others added 2 commits August 19, 2020 12:51
Signed-off-by: Giuseppe Scrivano <[email protected]>
Signed-off-by: Giuseppe Scrivano <[email protected]>
@giuseppe
Copy link
Member Author

Could we add any tests for this?

sure. Added tests

@AkihiroSuda
Copy link

@giuseppe
Copy link
Member Author

Support for Podman: containers/podman#7372

@rhatdan
Copy link
Member

rhatdan commented Aug 19, 2020

LGTM

@giuseppe
Copy link
Member Author

Can we have cgroup2 CI as in runc? https://github.com/opencontainers/runc/blob/2265daa55b594bea973e14bf1a22a7fe513ad334/.travis.yml#L24-L38

thanks for the hint. Yes I'll need to add CI for cgroup v2 (and also more tests :-) )

@giuseppe
Copy link
Member Author

if there are no blockers, let's move forward, we can always improve it later if needed

@mrunalp
Copy link

mrunalp commented Aug 21, 2020

Yeah sounds good

@mrunalp mrunalp merged commit 9417667 into containers:master Aug 21, 2020
giuseppe added a commit to giuseppe/libpod that referenced this pull request Aug 21, 2020
it allows to manually tweak the configuration for cgroup v2.

we will expose some of the options in future as single
options (e.g. the new memory knobs), but for now add the more generic
--cgroup-conf mechanism for maximum control on the cgroup
configuration.

OCI specs change: opencontainers/runtime-spec#1040

Requires: containers/crun#459

Signed-off-by: Giuseppe Scrivano <[email protected]>
int
read_all_file (const char *path, char **out, size_t *len, libcrun_error_t *err)
{
cleanup_close int fd = -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

A copy/paste bug? #483

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.

5 participants