-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Conversation
@@ -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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hqhq Added test. PTAL.
@hqhq I have added a test. PTAL. |
@@ -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"` |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ??
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
Signed-off-by: Buddha Prakash <[email protected]>
t.Fatalf("Failed to parse devices.allow - %s", err) | ||
} | ||
if value != allowedList { | ||
t.Fatal("Got the wrong value, set devices.allow failed.") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]>
@cyphar Updated the error message. PTAL. |
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]