Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
e3b1440
cgroups: add support for cpuset.mems
hqhq Dec 6, 2014
58fc931
Merge pull request #285 from hqhq/hq_add_cpuset_mems
vmarmol Dec 6, 2014
2f1b2ce
add support for testing execin
dqminh Dec 10, 2014
0195469
execin should honour rlimit of the container
dqminh Dec 10, 2014
6a76ecb
refactor common container setup out of execin tests
dqminh Dec 10, 2014
0d04027
Merge pull request #287 from dqminh/execin-test
crosbymichael Dec 10, 2014
19099e0
add spec for exec a new process inside a container
dqminh Dec 11, 2014
9184d94
cgroup: add support to set MemorySwap
hqhq Dec 11, 2014
6516e6c
user: MAINTAINERS: add cyphar as a maintainer
cyphar Dec 11, 2014
e9c1b01
fix some grammar errors
dqminh Dec 11, 2014
e8f5b54
Merge pull request #288 from hqhq/hq_add_memory_swap
Dec 11, 2014
eb2ae34
move cgroup requirements to planned additions
dqminh Dec 11, 2014
dc827aa
Merge pull request #289 from dqminh/execin-rlimit
Dec 11, 2014
2aebf7d
cgroups: add failcnt test
hqhq Dec 12, 2014
5fedffd
Merge pull request #295 from hqhq/hq_fix_memory_test
crosbymichael Dec 12, 2014
f925aa3
Merge pull request #294 from cyphar/user-add-cyphar-maintainer
crosbymichael Dec 12, 2014
c3ab8d0
Adding a function that allows to remove an address set on an interface
Ketouem Dec 12, 2014
1d72070
Rename of libcontainer image on Docker Hub
Dec 12, 2014
4940cee
Merge pull request #290 from dqminh/exec-spec
rjnagal Dec 12, 2014
42fed75
Merge pull request #297 from optiflows/delete_interface_ip
Dec 15, 2014
43842ef
reformat with indent -linux
dqminh Dec 15, 2014
b322073
user: *: fix function signatures
cyphar Dec 16, 2014
8a8eb57
*: merge to new user/ API
cyphar Dec 16, 2014
ef1c1c4
Merge pull request #301 from cyphar/user-fix-names
vmarmol Dec 16, 2014
4661c23
Add type for namespaces for better UI
crosbymichael Dec 16, 2014
2329014
Implement types for namespaces
crosbymichael Dec 17, 2014
d6cd7ce
define PR_SET_CHILD_SUBREAPER if not set
dqminh Dec 17, 2014
187792e
Merge pull request #293 from gaberger/292-makefilechange
crosbymichael Dec 19, 2014
08fdb50
Merge pull request #300 from dqminh/subreaper
Dec 19, 2014
9825a26
Refactor NotifyOnOOM a little
LK4D4 Dec 19, 2014
6feb7bd
Fix removing of cgroups if something still alive in container
LK4D4 Dec 22, 2014
f61899e
Merge pull request #308 from LK4D4/fix_cgroups_removing
rjnagal Dec 23, 2014
312f997
Allow non local mac-address.
jessfraz Dec 22, 2014
9455a8c
Merge pull request #310 from jfrazelle/9771-non-local-mac-address
rjnagal Dec 23, 2014
6423c8d
Merge pull request #307 from LK4D4/systemd_notify_oom
Dec 23, 2014
5bb8146
Add Contains wrapper for Namespaces type
LK4D4 Dec 23, 2014
1597c68
Merge pull request #312 from LK4D4/care_#302
Dec 23, 2014
6fae0d4
Add lk4d4 as maintainer
crosbymichael Dec 23, 2014
10d49f8
Merge pull request #313 from crosbymichael/lk4d4
rjnagal Dec 24, 2014
afb167a
Namespaces methods should act on pointer
crosbymichael Dec 24, 2014
0f397d4
Merge pull request #314 from crosbymichael/use-ns-ptr
LK4D4 Dec 24, 2014
c34b3d5
Fix vet errors
LK4D4 Dec 29, 2014
14af675
Merge pull request #316 from LK4D4/fix_vet
Jan 2, 2015
6c285c1
Changes Dockerfile to use go 1.4
mrunalp Jan 5, 2015
8067e34
Merge pull request #317 from mrunalp/go1.4
LK4D4 Jan 5, 2015
a1ac9b1
Use the child subreaper option only when available
mrunalp Jan 6, 2015
be02944
Merge pull request #318 from mrunalp/subreaper
crosbymichael Jan 6, 2015
e3184f9
Don't get stats for cgroups that don't exist.
vmarmol Jan 8, 2015
d7dea0e
Merge pull request #321 from vmarmol/no-file
crosbymichael Jan 8, 2015
445bebc
Adds functionality to specify additional groups to join.
mrunalp Jan 8, 2015
e30793a
Merge pull request #322 from mrunalp/features/add_groups
vmarmol Jan 8, 2015
1bd146e
This patch adds a test for the shared HOST Pid namespace
rhatdan Jan 7, 2015
b7e54b0
nsenter: add tests
avagin Dec 25, 2014
ecace12
nsenter: check errors from open(), read() and open()
avagin Dec 25, 2014
b6a1b88
nsenter: return an error if a process with specified pid doesn't exist
avagin Dec 25, 2014
0f8f060
nsenter: return an error if a process with specified pid is a zombie
avagin Dec 25, 2014
85cd869
nsenter: use %m instead of strerror(errno)
avagin Jan 6, 2015
35ae1c4
nsenter: add a macros to print errors
avagin Jan 6, 2015
50f0faa
Update ROADMAP.md to correctly reflect current arch status
estesp Jan 12, 2015
09809b5
Merge pull request #320 from rhatdan/pidns
crosbymichael Jan 12, 2015
2d9ef3a
Add config for running a container in host pid ns
crosbymichael Jan 12, 2015
4903df2
Refactor killAllPids
crosbymichael Jan 12, 2015
ba613c5
Merge pull request #315 from avagin/nsenter
Jan 12, 2015
6460fd7
Merge pull request #327 from crosbymichael/refactor-killAllPids
crosbymichael Jan 12, 2015
9377591
Merge pull request #326 from estesp/add-multiarch-info
vmarmol Jan 12, 2015
fec4c5a
Fix exit codes when dying on a signal
Jan 13, 2015
4bbd447
Add nsinit command to display oom notifications
crosbymichael Jan 13, 2015
dd6bc28
Merge pull request #329 from crosbymichael/oom-nsinit
vmarmol Jan 13, 2015
1d3b258
Merge pull request #328 from icecrime/signal_exit_code
Jan 13, 2015
13a5703
cgroups: don't change a freezer state if an operation failed
avagin Jan 14, 2015
29ba9b3
Merge pull request #335 from avagin/fixes
vmarmol Jan 15, 2015
9946e29
nsenter waits for parent signal before forking
dqminh Jan 8, 2015
f5dfd9a
nit: reindent with indent -linux
dqminh Jan 16, 2015
5a87153
fix TestNsenterAlivePid
dqminh Jan 16, 2015
73ba097
Merge pull request #336 from dqminh/execin-wait
crosbymichael Jan 16, 2015
54968f6
add support for blkio.weight
hqhq Jan 19, 2015
30b3306
cgroups: set a freezer state before calling FreezerGroup.Set()
avagin Jan 19, 2015
e451df7
namespace: don't create needless namespaces
avagin Dec 26, 2014
eb74393
Merge pull request #338 from avagin/fixes
Jan 19, 2015
b0eece8
Adds support for User Namespaces.
mrunalp Dec 17, 2014
b89cd0c
Merge pull request #304 from mrunalp/feature/user_namespaces
LK4D4 Jan 19, 2015
ef73d7e
namespace: don't change namespaces which are not belonged to the CT
avagin Dec 26, 2014
9303a8f
Merge pull request #324 from avagin/namespaces
Jan 20, 2015
107bad0
Adds namespace flag checks for userns code path in init.
mrunalp Jan 20, 2015
bde8bf2
Adds namespace flag checks to userns setup.
mrunalp Jan 20, 2015
5847aac
Merge pull request #340 from mrunalp/check_ns_flags
crosbymichael Jan 20, 2015
3fbf185
Merge pull request #337 from hqhq/hq_add_blkio_weight
crosbymichael Jan 20, 2015
eb84dd1
add dqminh as maintainer
dqminh Jan 22, 2015
c4821b6
cgroups: always create device cgroup on systemd
hqhq Jan 22, 2015
4657377
cgroups: simplify the join_memory check
hqhq Jan 22, 2015
2a452c1
Support read-only root filesystems
fabiokung Jan 22, 2015
cab4b9b
Merge pull request #345 from fabiokung/allow-readonly-rootfs
Jan 23, 2015
7d9244e
Fix a minor typo
guoxiuyan Jan 26, 2015
045e9ae
Merge pull request #347 from guoxiuyan/master
Jan 26, 2015
39fbf0a
Use cmd.Process.Wait instead of cmd.Wait
LK4D4 Jan 23, 2015
e05f807
Merge pull request #349 from LK4D4/replace_wait_for_wait4
crosbymichael Jan 26, 2015
c37b912
Merge pull request #344 from hqhq/hq_fix_systemd_device
vmarmol Jan 29, 2015
e9f8f85
Created man page for nsinit
Jan 20, 2015
2fac2da
Merge pull request #341 from shishir-a412ed/master
rjnagal Jan 29, 2015
689e8ec
Update github.com/godbus/dbus to v2
LK4D4 Jan 29, 2015
3c52181
Merge pull request #353 from LK4D4/update_dbus
vmarmol Jan 29, 2015
0890cc5
Add vet check to .drone.yml
LK4D4 Jan 30, 2015
e599843
Merge pull request #356 from LK4D4/vet_checks
Jan 30, 2015
444cc29
namespaces: allow to use pid namespace without mount namespace
avagin Jan 27, 2015
21c344a
update vendor/src/github.com/syndtr/gocapability/
avagin Feb 3, 2015
2da44f8
Merge pull request #358 from avagin/capabilities
vmarmol Feb 3, 2015
99233fd
cgroups: systemd: set DefaultDependencies=false if possible
Feb 4, 2015
4bd3999
Merge pull request #359 from philips/systemd-default-dependencies-false
Feb 5, 2015
e0de51f
Retry getting the cgroup root at apply time.
vmarmol Feb 6, 2015
62bdfc4
Merge pull request #362 from vmarmol/cgroup
Feb 6, 2015
f115a5f
fix typo and outdated comments in exec.go
hqhq Feb 7, 2015
623fe59
Merge pull request #361 from hqhq/hq_typo_for_userns
rjnagal Feb 7, 2015
da32455
Merge pull request #343 from dqminh/dqminh
crosbymichael Feb 9, 2015
da109f3
enable hairpin mode on virtual interface bridge port
phemmer Jul 1, 2014
770e258
handle SIGCHLD when running as child subreaper
dqminh Feb 10, 2015
d6fae7b
Merge pull request #369 from dqminh/exec-reap-zombie
Feb 10, 2015
190e50b
Selectively enable hairpin NAT
Feb 9, 2015
21ed476
Merge pull request #366 from icecrime/hairpin-nat
Feb 10, 2015
6262667
Changes required to keep gcc 5.0 quiet
rhatdan Feb 12, 2015
cee97cb
Merge pull request #372 from rhatdan/gcc5.0
Feb 12, 2015
ebefcdd
Use netlink to set hairpin mode
LK4D4 Feb 12, 2015
3f35b26
Merge pull request #373 from LK4D4/netlink_hairpin_support
crosbymichael Feb 13, 2015
f4cf808
Merge branch 'master' into api
crosbymichael Feb 16, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Rohit Jnagal <[email protected]> (@rjnagal)
Victor Marmol <[email protected]> (@vmarmol)
Mrunal Patel <[email protected]> (@mrunalp)
Alexandr Morozov <[email protected]> (@LK4D4)
Daniel, Dao Quang Minh <[email protected]> (@dqminh)
update-vendor.sh: Tianon Gravi <[email protected]> (@tianon)
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ sh:
GO_PACKAGES = $(shell find . -not \( -wholename ./vendor -prune -o -wholename ./.git -prune \) -name '*.go' -print0 | xargs -0n1 dirname | sort -u)

direct-test:
go get github.com/golang/glog && \
go test $(TEST_TAGS) -cover -v $(GO_PACKAGES)

direct-test-short:
Expand Down
1 change: 0 additions & 1 deletion apparmor/apparmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ func ApplyProfile(name string) error {
if name == "" {
return nil
}

cName := C.CString(name)
defer C.free(unsafe.Pointer(cName))

Expand Down
32 changes: 22 additions & 10 deletions cgroups/fs/apply_raw.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package fs

import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"sync"

"github.com/docker/libcontainer/cgroups"
"github.com/docker/libcontainer/configs"
Expand Down Expand Up @@ -40,20 +40,31 @@ type Manager struct {
}

// The absolute path to the root of the cgroup hierarchies.
var cgroupRootLock sync.Mutex
var cgroupRoot string

// TODO(vmarmol): Report error here, we'll probably need to wait for the new API.
func init() {
// Gets the cgroupRoot.
func getCgroupRoot() (string, error) {
cgroupRootLock.Lock()
defer cgroupRootLock.Unlock()

if cgroupRoot != "" {
return cgroupRoot, nil
}

// we can pick any subsystem to find the root
cpuRoot, err := cgroups.FindCgroupMountpoint("cpu")
if err != nil {
return
return "", err
}
cgroupRoot = filepath.Dir(cpuRoot)
root := filepath.Dir(cpuRoot)

if _, err := os.Stat(cgroupRoot); err != nil {
return
if _, err := os.Stat(root); err != nil {
return "", err
}

cgroupRoot = root
return cgroupRoot, nil
}

type data struct {
Expand Down Expand Up @@ -172,8 +183,9 @@ func (m *Manager) GetPids() ([]int, error) {
}

func getCgroupData(c *configs.Cgroup, pid int) (*data, error) {
if cgroupRoot == "" {
return nil, fmt.Errorf("failed to find the cgroup root")
root, err := getCgroupRoot()
if err != nil {
return nil, err
}

cgroup := c.Name
Expand All @@ -182,7 +194,7 @@ func getCgroupData(c *configs.Cgroup, pid int) (*data, error) {
}

return &data{
root: cgroupRoot,
root: root,
cgroup: cgroup,
c: c,
pid: pid,
Expand Down
40 changes: 28 additions & 12 deletions cgroups/systemd/apply_systemd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ type subsystem interface {
}

var (
connLock sync.Mutex
theConn *systemd.Conn
hasStartTransientUnit bool
connLock sync.Mutex
theConn *systemd.Conn
hasStartTransientUnit bool
hasTransientDefaultDependencies bool
)

func newProp(name string, units interface{}) systemd.Property {
Expand Down Expand Up @@ -66,6 +67,18 @@ func UseSystemd() bool {
if dbusError, ok := err.(dbus.Error); ok {
if dbusError.Name == "org.freedesktop.DBus.Error.UnknownMethod" {
hasStartTransientUnit = false
return hasStartTransientUnit
}
}
}

// Assume StartTransientUnit on a scope allows DefaultDependencies
hasTransientDefaultDependencies = true
ddf := newProp("DefaultDependencies", false)
if _, err := theConn.StartTransientUnit("docker-systemd-test-default-dependencies.scope", "replace", ddf); err != nil {
if dbusError, ok := err.(dbus.Error); ok {
if dbusError.Name == "org.freedesktop.DBus.Error.PropertyReadOnly" {
hasTransientDefaultDependencies = false
}
}
}
Expand Down Expand Up @@ -108,6 +121,11 @@ func (m *Manager) Apply(pid int) error {
newProp("CPUAccounting", true),
newProp("BlockIOAccounting", true))

if hasTransientDefaultDependencies {
properties = append(properties,
newProp("DefaultDependencies", false))
}

if c.Memory != 0 {
properties = append(properties,
newProp("MemoryLimit", uint64(c.Memory)))
Expand All @@ -128,14 +146,12 @@ func (m *Manager) Apply(pid int) error {
return err
}

if !c.AllowAllDevices {
if err := joinDevices(c, pid); err != nil {
return err
}
if err := joinDevices(c, pid); err != nil {
return err
}

// -1 disables memorySwap
if c.MemorySwap >= 0 && (c.Memory != 0 || c.MemorySwap > 0) {
if c.MemorySwap >= 0 && c.Memory != 0 {
if err := joinMemory(c, pid); err != nil {
return err
}
Expand Down Expand Up @@ -290,16 +306,16 @@ func joinDevices(c *configs.Cgroup, pid int) error {
return err
}

if err := writeFile(path, "devices.deny", "a"); err != nil {
return err
if !c.AllowAllDevices {
if err := writeFile(path, "devices.deny", "a"); err != nil {
return err
}
}

for _, dev := range c.AllowedDevices {
if err := writeFile(path, "devices.allow", dev.CgroupString()); err != nil {
return err
}
}

return nil
}

Expand Down
8 changes: 4 additions & 4 deletions configs/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func TestHostUIDNoUSERNS(t *testing.T) {
t.Fatal(err)
}
if uid != 0 {
t.Fatal("expected uid 0 with no USERNS but received %d", uid)
t.Fatalf("expected uid 0 with no USERNS but received %d", uid)
}
}

Expand All @@ -182,7 +182,7 @@ func TestHostUIDWithUSERNS(t *testing.T) {
t.Fatal(err)
}
if uid != 1000 {
t.Fatal("expected uid 1000 with no USERNS but received %d", uid)
t.Fatalf("expected uid 1000 with no USERNS but received %d", uid)
}
}

Expand All @@ -195,7 +195,7 @@ func TestHostGIDNoUSERNS(t *testing.T) {
t.Fatal(err)
}
if uid != 0 {
t.Fatal("expected gid 0 with no USERNS but received %d", uid)
t.Fatalf("expected gid 0 with no USERNS but received %d", uid)
}
}

Expand All @@ -215,6 +215,6 @@ func TestHostGIDWithUSERNS(t *testing.T) {
t.Fatal(err)
}
if uid != 1000 {
t.Fatal("expected gid 1000 with no USERNS but received %d", uid)
t.Fatalf("expected gid 1000 with no USERNS but received %d", uid)
}
}
38 changes: 38 additions & 0 deletions docs/man/nsinit.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% nsinit User Manual
% docker/libcontainer
% JAN 2015

NAME:
nsinit - A low-level utility for managing containers.
It is used to spawn new containers or join existing containers.

USAGE:
nsinit [global options] command [command options] [arguments...]

VERSION:
0.1

COMMANDS:
config display the container configuration
exec execute a new command inside a container
init runs the init process inside the namespace
oom display oom notifications for a container
pause pause the container's processes
stats display statistics for the container
unpause unpause the container's processes
help, h shows a list of commands or help for one command

EXAMPLES:

Get the <container_id> of an already running docker container.
`sudo docker ps` will return the list of all the running containers.

take the <container_id> (e.g. 4addb0b2d307) and go to its config directory
`/var/lib/docker/execdriver/native/4addb0b2d307` and here you can run the nsinit
command line utility.

e.g. `nsinit exec /bin/bash` will start a shell on the already running container.

# HISTORY
Jan 2015, Originally compiled by Shishir Mahajan (shishir dot mahajan at redhat dot com)
based on nsinit source material and internal work.
132 changes: 132 additions & 0 deletions integration/execin_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package integration

import (
"os"
"strings"
"syscall"
"testing"

"github.com/docker/libcontainer"
)

func TestExecIn(t *testing.T) {
if testing.Short() {
return
}
rootfs, err := newRootfs()
if err != nil {
t.Fatal(err)
}
defer remove(rootfs)
config := newTemplateConfig(rootfs)
container, err := newContainer(config)
if err != nil {
t.Fatal(err)
}
defer container.Destroy()
buffers := newStdBuffers()
process := &libcontainer.Process{
Args: []string{"sleep", "10"},
Env: standardEnvironment,
Stdin: buffers.Stdin,
Stdout: buffers.Stdout,
Stderr: buffers.Stderr,
}
pid1, err := container.Start(process)
if err != nil {
t.Fatal(err)
}
buffers = newStdBuffers()
psPid, err := container.Start(&libcontainer.Process{
Args: []string{"ps"},
Env: standardEnvironment,
Stdin: buffers.Stdin,
Stdout: buffers.Stdout,
Stderr: buffers.Stderr,
})
if err != nil {
t.Fatal(err)
}
ps, err := os.FindProcess(psPid)
if err != nil {
t.Fatal(err)
}
if _, err := ps.Wait(); err != nil {
t.Fatal(err)
}
p, err := os.FindProcess(pid1)
if err != nil {
t.Fatal(err)
}
if err := p.Signal(syscall.SIGKILL); err != nil {
t.Log(err)
}
if _, err := p.Wait(); err != nil {
t.Log(err)
}
out := buffers.Stdout.String()
if !strings.Contains(out, "sleep 10") || !strings.Contains(out, "ps") {
t.Fatalf("unexpected running process, output %q", out)
}
}

func TestExecInRlimit(t *testing.T) {
if testing.Short() {
return
}
rootfs, err := newRootfs()
if err != nil {
t.Fatal(err)
}
defer remove(rootfs)
config := newTemplateConfig(rootfs)
container, err := newContainer(config)
if err != nil {
t.Fatal(err)
}
defer container.Destroy()
buffers := newStdBuffers()
process := &libcontainer.Process{
Args: []string{"sleep", "10"},
Env: standardEnvironment,
Stdin: buffers.Stdin,
Stdout: buffers.Stdout,
Stderr: buffers.Stderr,
}
pid1, err := container.Start(process)
if err != nil {
t.Fatal(err)
}
buffers = newStdBuffers()
psPid, err := container.Start(&libcontainer.Process{
Args: []string{"/bin/sh", "-c", "ulimit -n"},
Env: standardEnvironment,
Stdin: buffers.Stdin,
Stdout: buffers.Stdout,
Stderr: buffers.Stderr,
})
if err != nil {
t.Fatal(err)
}
ps, err := os.FindProcess(psPid)
if err != nil {
t.Fatal(err)
}
if _, err := ps.Wait(); err != nil {
t.Fatal(err)
}
p, err := os.FindProcess(pid1)
if err != nil {
t.Fatal(err)
}
if err := p.Signal(syscall.SIGKILL); err != nil {
t.Log(err)
}
if _, err := p.Wait(); err != nil {
t.Log(err)
}
out := buffers.Stdout.String()
if limit := strings.TrimSpace(out); limit != "1024" {
t.Fatalf("expected rlimit to be 1024, got %s", limit)
}
}
5 changes: 3 additions & 2 deletions integration/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func init() {
if err != nil {
log.Fatalf("unable to initialize for container: %s", err)
}
factory.StartInitialization(3)
os.Exit(1)
if err := factory.StartInitialization(3); err != nil {
log.Fatal(err)
}
}
Loading