Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lxc: get rid of custom container detection code
The mechanism for detecting whether or not the task is in a container here (checking if we're in the / cgroup) is very broken, and will not work with cgroup namespaces (to land in kernel 4.5, but will be backported to xenial's 4.4 kernel). Instead, we should use the running-in-container script, as provided by the init-system-helpers package, which encapsulates all the logic required for various init systems. (n.b. that this adds a dependency; I'm not sure how juju handles this.) Also, I've mode the code to container/ instead of in lxc/lxcutils in anticipation of the lxd container type which will also need to use this function. Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com>
- Loading branch information
Tycho Andersen
committed
Feb 4, 2016
1 parent
b59d585
commit 24fef1a
Showing
8 changed files
with
17 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package container | ||
|
||
import ( | ||
"os/exec" | ||
) | ||
|
||
func RunningInContainer() bool { | ||
/* running-in-container is in init-scripts-helpers, and is smart enough | ||
* to ask both systemd and upstart whether or not they know if the task | ||
* is running in a container. | ||
*/ | ||
cmd := exec.Command("running-in-container") | ||
return cmd.Run() == nil | ||
} |