[lxc-devel] [PATCH] fix attach when cgroups mounted after container start

Serge Hallyn serge.hallyn at ubuntu.com
Wed Feb 26 19:46:41 UTC 2014


Quoting Dwight Engen (dwight.engen at oracle.com):
> When booting an OL7 container on OL6, systemd in the OL7 container mounted
> some extra cgroup controllers, which are then present in /proc/self/cgroups
> of every task on the host. This is the list used by attach to determine
> which cgroups to move the attached task into, but when it asks the container
> over the command interface for the path to the subsystem this will fail
> since the controller didn't exist when the container was first started.
> 
> Instead of failing, this change allows the attach to continue, warning that
> those cgroups that could not be found won't be attached to.
> 
> The problem can be more simply reproduced by starting a busybox container,
> mounting a cgroup that was not previously mounted, and then attempting
> to attach to to the busybox container.
> 
> The problem will likely not manifest with cgmanager since it only requests
> the path for the first controller, which is likely to always be mounted.
> 
> Signed-off-by: Dwight Engen <dwight.engen at oracle.com>

That does seem sensible.  Thanks.

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/cgfs.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/cgfs.c b/src/lxc/cgfs.c
> index ff848e9..db2a973 100644
> --- a/src/lxc/cgfs.c
> +++ b/src/lxc/cgfs.c
> @@ -1095,8 +1095,11 @@ static struct cgroup_process_info *lxc_cgroup_get_container_info(const char *nam
>  
>  		/* use the command interface to look for the cgroup */
>  		path = lxc_cmd_get_cgroup_path(name, lxcpath, h->subsystems[0]);
> -		if (!path)
> -			goto out_error;
> +		if (!path) {
> +			h->used = false;
> +			WARN("Not attaching to cgroup %s unknown to %s %s", h->subsystems[0], lxcpath, name);
> +			continue;
> +		}
>  
>  		entry = calloc(1, sizeof(struct cgroup_process_info));
>  		if (!entry)
> -- 
> 1.8.5.3
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list