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

Skip updates on parent Devices cgroup #958

Merged
merged 2 commits into from
Jul 29, 2016

Conversation

dubstack
Copy link

temporary fix for #932

I am currently working on introducing a cgroup hierarchy in the node in Kubernetes. See (kubernetes/kubernetes#27204)

Allowing or denying all devices by writing 'a' to devices.allow or devices.deny is
not possible once the device cgroups has children. As a libcontainer user I should atleast have the option of skipping updates on devices cgroup.

cc @cyphar @vishh @derekwaynecarr @mrunalp
Signed-off-by: Buddha Prakash [email protected]

@@ -66,7 +66,8 @@ func TestDevicesSetDeny(t *testing.T) {
"devices.allow": "a",
})

helper.CgroupData.config.Resources.AllowAllDevices = true
allowAllDevices := true
helper.CgroupData.config.Resources.AllowAllDevices = &allowAllDevices
helper.CgroupData.config.Resources.DeniedDevices = deniedDevices
devices := &DevicesGroup{}
if err := devices.Set(helper.CgroupPath, helper.CgroupData.config); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a test that AllowAllDevices is nil, and make sure it won't change the old data?

Copy link
Author

Choose a reason for hiding this comment

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

@hqhq Added test. PTAL.

@dubstack
Copy link
Author

@hqhq I have added a test. PTAL.

cc @mrunalp @derekwaynecarr @cyphar

@@ -36,7 +36,7 @@ type Cgroup struct {
type Resources struct {
// If this is true allow access to any kind of device within the container. If false, allow access only to devices explicitly listed in the allowed_devices list.
// Deprecated
AllowAllDevices bool `json:"allow_all_devices,omitempty"`
Copy link
Contributor

@vishh vishh Jul 24, 2016

Choose a reason for hiding this comment

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

Why did you drop the omitempty tag? That is meant to qualify if a field is optional or not.

Copy link
Author

Choose a reason for hiding this comment

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

I thought we would want to omit the field from the object if its Nil ??

Copy link
Contributor

Choose a reason for hiding this comment

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

To omit a field you need to specify omitempty.

Copy link
Author

Choose a reason for hiding this comment

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

Oh no. BrainFart. I will fix that in a sec.

@hqhq
Copy link
Contributor

hqhq commented Jul 26, 2016

LGTM, thanks.

Approved with PullApprove

@dubstack
Copy link
Author

@mrunalp @cyphar PTAL.

t.Fatalf("Failed to parse devices.allow - %s", err)
}
if value != allowedList {
t.Fatal("Got the wrong value, set devices.allow failed.")
Copy link
Member

@cyphar cyphar Jul 29, 2016

Choose a reason for hiding this comment

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

Please make this error message descriptive of the actual error. Something like AllowAllDevices = nil changed devices policy. Otherwise grepping for the test failure message is a pain.

Copy link
Author

Choose a reason for hiding this comment

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

Makes sense! will make the change.

Signed-off-by: Buddha Prakash <[email protected]>
@dubstack
Copy link
Author

@cyphar Updated the error message. PTAL.

@cyphar
Copy link
Member

cyphar commented Jul 29, 2016

LGTM

/cc @opencontainers/runc-maintainers

Approved with PullApprove

@hqhq
Copy link
Contributor

hqhq commented Jul 29, 2016

LGTM

Approved with PullApprove

@hqhq hqhq merged commit 1a81e9a into opencontainers:master Jul 29, 2016
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.

5 participants