Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

don't fail when subsystem not mounted #476

Merged
merged 1 commit into from
May 11, 2015

Conversation

hqhq
Copy link
Contributor

@hqhq hqhq commented Mar 24, 2015

We do this aim two goals:

  • don't fail when some subsystems are not mounted.
  • fail hard instead of ignoring the error when a user specifies
    an option and we are unable to fulfill the request.

Signed-off-by: Qiang Huang h.huangqiang@huawei.com

@@ -10,7 +10,7 @@ type DevicesGroup struct {

func (s *DevicesGroup) Apply(d *data) error {
dir, err := d.join("devices")
if err != nil {
if err != nil && !cgroups.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We really cannot do this because devices is a hard requirement. Without the devices cgroup it is a security issue because a container will have unrestricted access to device nodes.

@crosbymichael
Copy link
Contributor

@hqhq what cgroups does your systems not have mounted?

@hqhq
Copy link
Contributor Author

hqhq commented Mar 25, 2015

@crosbymichael some of our clients don't mount all cgroup subsystems, maybe just mount cpuset and memory cgroup. It's OK if Docker take device cgroup as hard requirement, but I think that can be done on Docker side, because that's what Docker needed, and we can show specific message, libcontainer should be more common, what do you think?

@crosbymichael
Copy link
Contributor

@hqhq I think cgroups are a fundamental aspect for creating containers and support should be required. There is little overhead for mounting these and joining them as monitoring via cgroups is very important to understand the performance of your containerized apps. I feel like containers are the sum of namespaces, cgroups, caps, and rootfs jails (chroot). Each are equally important and should be required.

@vmarmol how do you feel about making these mounts required or not?

@vmarmol
Copy link
Contributor

vmarmol commented Mar 25, 2015

I see @hqhq's point about libcontainer maybe not being the place where we enforce this, but I do see the value in having a setup we know and test frequently. We already assume cgroups are mounted in various places and it'll be brittle for those that don't. I'm conflicted but I side with @crosbymichael about having a good experience for the 99% usecases.

@hqhq
Copy link
Contributor Author

hqhq commented Mar 28, 2015

@crosbymichael @vmarmol I don't think we should take all cgroup subsystems as hard requirement, devices cgroup has a good reason but not all of others. I added some check on Docker side moby/moby#11882, and we can take devices cgroup as hard requirement in libcontaier.

@hqhq hqhq force-pushed the hq_dont_fail_subsystem branch from 3e65a95 to 2d6ee23 Compare March 28, 2015 10:02
@hqhq
Copy link
Contributor Author

hqhq commented Mar 28, 2015

I updated devices part, WDYT?

@crosbymichael
Copy link
Contributor

@hqhq ok, i think that maybe a good approach to take.

// Normally dir should not be empty, one case is that cgroup subsystem
// is not mounted, we will get empty dir, and we want it fail here.
if dir == "" {
return fmt.Errorf("No such directory for %s.", file)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: lowercase "No" for Go errors to start with lowercase.

@vmarmol
Copy link
Contributor

vmarmol commented Mar 30, 2015

Sounds reasonable to me.

@hqhq hqhq force-pushed the hq_dont_fail_subsystem branch from 2d6ee23 to 1bcb6f3 Compare March 31, 2015 02:53
@hqhq
Copy link
Contributor Author

hqhq commented Mar 31, 2015

Updated.

@mrunalp
Copy link
Contributor

mrunalp commented Mar 31, 2015

@hqhq Do we need any changes on the systemd side?

@hqhq hqhq force-pushed the hq_dont_fail_subsystem branch from 1bcb6f3 to e10bc4b Compare April 1, 2015 06:31
@hqhq
Copy link
Contributor Author

hqhq commented Apr 1, 2015

@mrunalp Yes we need indeed, updated, thanks.

@hqhq hqhq force-pushed the hq_dont_fail_subsystem branch from e10bc4b to a824f09 Compare April 15, 2015 07:53
@hqhq
Copy link
Contributor Author

hqhq commented Apr 15, 2015

Rebased, ping.

@hqhq
Copy link
Contributor Author

hqhq commented Apr 22, 2015

ping.

if path == "" {
return nil
}

Copy link
Contributor

Choose a reason for hiding this comment

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

should this check be moved into cpusetGroup.ApplyDir ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks, updated.

@vishh
Copy link
Contributor

vishh commented Apr 22, 2015

This still doesn't satisfy the use case where no cgroups are mounted right?

We do this aim two goals:
 - don't fail when some subsystems are not mounted (devices cgroup
   is an exception because it will cause secirity issues).
 - fail hard instead of ignoring the error when a user specifies
   an option and we are unable to fulfill the request.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
@hqhq
Copy link
Contributor Author

hqhq commented Apr 22, 2015

@vishh No, for now devices cgroup is hard requirement for security.

@hqhq hqhq force-pushed the hq_dont_fail_subsystem branch from a824f09 to 27d3dd3 Compare April 22, 2015 03:10
@dqminh
Copy link
Contributor

dqminh commented Apr 22, 2015

LGTM

@@ -48,6 +48,11 @@ func (s *CpusetGroup) GetStats(path string, stats *cgroups.Stats) error {
}

func (s *CpusetGroup) ApplyDir(dir string, cgroup *configs.Cgroup, pid int) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we not even make the call to apply for this subsystem if it doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was outside, just moved in as @dqminh suggested.
If outside, we should do that on both fs and systemd side, but I don't think that's a big deal. Just want make sure which way you prefer.

Choose a reason for hiding this comment

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

Yeah, checking this outside would duplicate this logic, I like it here better too 👍

@calavera
Copy link

code LGTM.

@hqhq
Copy link
Contributor Author

hqhq commented May 11, 2015

ping.

@dqminh
Copy link
Contributor

dqminh commented May 11, 2015

LGTM

1 similar comment
@vmarmol
Copy link
Contributor

vmarmol commented May 11, 2015

LGTM

vmarmol added a commit that referenced this pull request May 11, 2015
don't fail when subsystem not mounted
@vmarmol vmarmol merged commit a37b2a4 into docker-archive:master May 11, 2015
@hqhq hqhq deleted the hq_dont_fail_subsystem branch May 12, 2015 01:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants