Merge pull request #13071 from tianon/explicit-vendor
Update "hack/vendor.sh" to be more explicit
This commit is contained in:
commit
23abd51ef1
14 changed files with 108 additions and 112 deletions
|
@ -36,26 +36,23 @@ clone() {
|
||||||
echo -n 'rm VCS, '
|
echo -n 'rm VCS, '
|
||||||
( cd $target_dir && rm -rf .{git,hg} )
|
( cd $target_dir && rm -rf .{git,hg} )
|
||||||
|
|
||||||
|
echo -n 'rm vendor, '
|
||||||
|
( cd $target_dir && rm -rf vendor Godeps/_workspace )
|
||||||
|
|
||||||
echo done
|
echo done
|
||||||
}
|
}
|
||||||
|
|
||||||
clone git github.com/kr/pty 05017fcccf
|
# the following lines are in sorted order, FYI
|
||||||
|
clone git github.com/Sirupsen/logrus v0.7.3 # logrus is a common dependency among multiple deps
|
||||||
clone git github.com/gorilla/context 14f550f51a
|
|
||||||
|
|
||||||
clone git github.com/gorilla/mux e444e69cbd
|
|
||||||
|
|
||||||
clone git github.com/tchap/go-patricia v2.1.0
|
|
||||||
|
|
||||||
clone hg code.google.com/p/go.net 84a4013f96e0
|
|
||||||
|
|
||||||
clone hg code.google.com/p/gosqlite 74691fb6f837
|
|
||||||
|
|
||||||
clone git github.com/docker/libtrust 230dfd18c232
|
clone git github.com/docker/libtrust 230dfd18c232
|
||||||
|
|
||||||
clone git github.com/go-fsnotify/fsnotify v1.2.0
|
|
||||||
|
|
||||||
clone git github.com/go-check/check 64131543e7896d5bcc6bd5a76287eb75ea96c673
|
clone git github.com/go-check/check 64131543e7896d5bcc6bd5a76287eb75ea96c673
|
||||||
|
clone git github.com/go-fsnotify/fsnotify v1.2.0
|
||||||
|
clone git github.com/gorilla/context 14f550f51a
|
||||||
|
clone git github.com/gorilla/mux e444e69cbd
|
||||||
|
clone git github.com/kr/pty 05017fcccf
|
||||||
|
clone git github.com/tchap/go-patricia v2.1.0
|
||||||
|
clone hg code.google.com/p/go.net 84a4013f96e0
|
||||||
|
clone hg code.google.com/p/gosqlite 74691fb6f837
|
||||||
|
|
||||||
# get distribution packages
|
# get distribution packages
|
||||||
clone git github.com/docker/distribution d957768537c5af40e4f4cd96871f7b2bde9e2923
|
clone git github.com/docker/distribution d957768537c5af40e4f4cd96871f7b2bde9e2923
|
||||||
|
@ -67,8 +64,8 @@ mv tmp-digest src/github.com/docker/distribution/digest
|
||||||
mkdir -p src/github.com/docker/distribution/registry
|
mkdir -p src/github.com/docker/distribution/registry
|
||||||
mv tmp-api src/github.com/docker/distribution/registry/api
|
mv tmp-api src/github.com/docker/distribution/registry/api
|
||||||
|
|
||||||
clone git github.com/docker/libcontainer 1b471834b45063b61e0aedefbb1739a8f34b414e
|
clone git github.com/docker/libcontainer 90f8aa670f1f424041059060c7c63fe4dee2e441
|
||||||
# see src/github.com/docker/libcontainer/update-vendor.sh which is the "source of truth" for libcontainer deps (just like this file)
|
# libcontainer deps (see src/github.com/docker/libcontainer/update-vendor.sh)
|
||||||
rm -rf src/github.com/docker/libcontainer/vendor
|
clone git github.com/coreos/go-systemd v2
|
||||||
eval "$(grep '^clone ' src/github.com/docker/libcontainer/update-vendor.sh | grep -v 'github.com/codegangsta/cli')"
|
clone git github.com/godbus/dbus v2
|
||||||
# we exclude "github.com/codegangsta/cli" here because it's only needed for "nsinit", which Docker doesn't include
|
clone git github.com/syndtr/gocapability 8e4cdcb
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
bundles
|
bundles
|
||||||
nsinit/nsinit
|
nsinit/nsinit
|
||||||
|
vendor/pkg
|
||||||
|
|
|
@ -15,7 +15,7 @@ with a strong security configuration.
|
||||||
### System Requirements and Compatibility
|
### System Requirements and Compatibility
|
||||||
|
|
||||||
Minimum requirements:
|
Minimum requirements:
|
||||||
* Kernel version - 3.8 recommended 2.6.2x minimum(with backported patches)
|
* Kernel version - 3.10 recommended 2.6.2x minimum(with backported patches)
|
||||||
* Mounted cgroups with each subsystem in its own hierarchy
|
* Mounted cgroups with each subsystem in its own hierarchy
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,11 +28,9 @@ Minimum requirements:
|
||||||
| CLONE_NEWIPC | 1 |
|
| CLONE_NEWIPC | 1 |
|
||||||
| CLONE_NEWNET | 1 |
|
| CLONE_NEWNET | 1 |
|
||||||
| CLONE_NEWNS | 1 |
|
| CLONE_NEWNS | 1 |
|
||||||
| CLONE_NEWUSER | 0 |
|
| CLONE_NEWUSER | 1 |
|
||||||
|
|
||||||
In v1 the user namespace is not enabled by default for support of older kernels
|
Namespaces are created for the container via the `clone` syscall.
|
||||||
where the user namespace feature is not fully implemented. Namespaces are
|
|
||||||
created for the container via the `clone` syscall.
|
|
||||||
|
|
||||||
|
|
||||||
### Filesystem
|
### Filesystem
|
||||||
|
@ -143,6 +141,7 @@ system resources like cpu, memory, and device access.
|
||||||
| blkio | 1 |
|
| blkio | 1 |
|
||||||
| perf_event | 1 |
|
| perf_event | 1 |
|
||||||
| freezer | 1 |
|
| freezer | 1 |
|
||||||
|
| hugetlb | 1 |
|
||||||
|
|
||||||
|
|
||||||
All cgroup subsystem are joined so that statistics can be collected from
|
All cgroup subsystem are joined so that statistics can be collected from
|
||||||
|
@ -165,6 +164,7 @@ provide a good default for security and flexibility for the applications.
|
||||||
| -------------------- | ------- |
|
| -------------------- | ------- |
|
||||||
| CAP_NET_RAW | 1 |
|
| CAP_NET_RAW | 1 |
|
||||||
| CAP_NET_BIND_SERVICE | 1 |
|
| CAP_NET_BIND_SERVICE | 1 |
|
||||||
|
| CAP_AUDIT_READ | 1 |
|
||||||
| CAP_AUDIT_WRITE | 1 |
|
| CAP_AUDIT_WRITE | 1 |
|
||||||
| CAP_DAC_OVERRIDE | 1 |
|
| CAP_DAC_OVERRIDE | 1 |
|
||||||
| CAP_SETFCAP | 1 |
|
| CAP_SETFCAP | 1 |
|
||||||
|
@ -304,6 +304,7 @@ a container.
|
||||||
| Pause | Pause all processes inside the container |
|
| Pause | Pause all processes inside the container |
|
||||||
| Resume | Resume all processes inside the container if paused |
|
| Resume | Resume all processes inside the container if paused |
|
||||||
| Exec | Execute a new process inside of the container ( requires setns ) |
|
| Exec | Execute a new process inside of the container ( requires setns ) |
|
||||||
|
| Set | Setup configs of the container after it's created |
|
||||||
|
|
||||||
### Execute a new process inside of a running container.
|
### Execute a new process inside of a running container.
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -23,75 +23,75 @@ func blkioStatEntryEquals(expected, actual []cgroups.BlkioStatEntry) error {
|
||||||
|
|
||||||
func expectBlkioStatsEquals(t *testing.T, expected, actual cgroups.BlkioStats) {
|
func expectBlkioStatsEquals(t *testing.T, expected, actual cgroups.BlkioStats) {
|
||||||
if err := blkioStatEntryEquals(expected.IoServiceBytesRecursive, actual.IoServiceBytesRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoServiceBytesRecursive, actual.IoServiceBytesRecursive); err != nil {
|
||||||
log.Printf("blkio IoServiceBytesRecursive do not match - %s\n", err)
|
logrus.Printf("blkio IoServiceBytesRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.IoServicedRecursive, actual.IoServicedRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoServicedRecursive, actual.IoServicedRecursive); err != nil {
|
||||||
log.Printf("blkio IoServicedRecursive do not match - %s\n", err)
|
logrus.Printf("blkio IoServicedRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.IoQueuedRecursive, actual.IoQueuedRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoQueuedRecursive, actual.IoQueuedRecursive); err != nil {
|
||||||
log.Printf("blkio IoQueuedRecursive do not match - %s\n", err)
|
logrus.Printf("blkio IoQueuedRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.SectorsRecursive, actual.SectorsRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.SectorsRecursive, actual.SectorsRecursive); err != nil {
|
||||||
log.Printf("blkio SectorsRecursive do not match - %s\n", err)
|
logrus.Printf("blkio SectorsRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.IoServiceTimeRecursive, actual.IoServiceTimeRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoServiceTimeRecursive, actual.IoServiceTimeRecursive); err != nil {
|
||||||
log.Printf("blkio IoServiceTimeRecursive do not match - %s\n", err)
|
logrus.Printf("blkio IoServiceTimeRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.IoWaitTimeRecursive, actual.IoWaitTimeRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoWaitTimeRecursive, actual.IoWaitTimeRecursive); err != nil {
|
||||||
log.Printf("blkio IoWaitTimeRecursive do not match - %s\n", err)
|
logrus.Printf("blkio IoWaitTimeRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.IoMergedRecursive, actual.IoMergedRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoMergedRecursive, actual.IoMergedRecursive); err != nil {
|
||||||
log.Printf("blkio IoMergedRecursive do not match - %v vs %v\n", expected.IoMergedRecursive, actual.IoMergedRecursive)
|
logrus.Printf("blkio IoMergedRecursive do not match - %v vs %v\n", expected.IoMergedRecursive, actual.IoMergedRecursive)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := blkioStatEntryEquals(expected.IoTimeRecursive, actual.IoTimeRecursive); err != nil {
|
if err := blkioStatEntryEquals(expected.IoTimeRecursive, actual.IoTimeRecursive); err != nil {
|
||||||
log.Printf("blkio IoTimeRecursive do not match - %s\n", err)
|
logrus.Printf("blkio IoTimeRecursive do not match - %s\n", err)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func expectThrottlingDataEquals(t *testing.T, expected, actual cgroups.ThrottlingData) {
|
func expectThrottlingDataEquals(t *testing.T, expected, actual cgroups.ThrottlingData) {
|
||||||
if expected != actual {
|
if expected != actual {
|
||||||
log.Printf("Expected throttling data %v but found %v\n", expected, actual)
|
logrus.Printf("Expected throttling data %v but found %v\n", expected, actual)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats) {
|
func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats) {
|
||||||
if expected.Usage != actual.Usage {
|
if expected.Usage != actual.Usage {
|
||||||
log.Printf("Expected memory usage %d but found %d\n", expected.Usage, actual.Usage)
|
logrus.Printf("Expected memory usage %d but found %d\n", expected.Usage, actual.Usage)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if expected.MaxUsage != actual.MaxUsage {
|
if expected.MaxUsage != actual.MaxUsage {
|
||||||
log.Printf("Expected memory max usage %d but found %d\n", expected.MaxUsage, actual.MaxUsage)
|
logrus.Printf("Expected memory max usage %d but found %d\n", expected.MaxUsage, actual.MaxUsage)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
for key, expValue := range expected.Stats {
|
for key, expValue := range expected.Stats {
|
||||||
actValue, ok := actual.Stats[key]
|
actValue, ok := actual.Stats[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Printf("Expected memory stat key %s not found\n", key)
|
logrus.Printf("Expected memory stat key %s not found\n", key)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
if expValue != actValue {
|
if expValue != actValue {
|
||||||
log.Printf("Expected memory stat value %d but found %d\n", expValue, actValue)
|
logrus.Printf("Expected memory stat value %d but found %d\n", expValue, actValue)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if expected.Failcnt != actual.Failcnt {
|
if expected.Failcnt != actual.Failcnt {
|
||||||
log.Printf("Expected memory failcnt %d but found %d\n", expected.Failcnt, actual.Failcnt)
|
logrus.Printf("Expected memory failcnt %d but found %d\n", expected.Failcnt, actual.Failcnt)
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"sync"
|
"sync"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
"github.com/docker/libcontainer/configs"
|
"github.com/docker/libcontainer/configs"
|
||||||
)
|
)
|
||||||
|
@ -102,7 +102,7 @@ func (c *linuxContainer) Start(process *Process) error {
|
||||||
if err := parent.start(); err != nil {
|
if err := parent.start(); err != nil {
|
||||||
// terminate the process to ensure that it properly is reaped.
|
// terminate the process to ensure that it properly is reaped.
|
||||||
if err := parent.terminate(); err != nil {
|
if err := parent.terminate(); err != nil {
|
||||||
log.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
return newSystemError(err)
|
return newSystemError(err)
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ func (c *linuxContainer) Destroy() error {
|
||||||
}
|
}
|
||||||
if !c.config.Namespaces.Contains(configs.NEWPID) {
|
if !c.config.Namespaces.Contains(configs.NEWPID) {
|
||||||
if err := killCgroupProcesses(c.cgroupManager); err != nil {
|
if err := killCgroupProcesses(c.cgroupManager); err != nil {
|
||||||
log.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
err = c.cgroupManager.Destroy()
|
err = c.cgroupManager.Destroy()
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
"github.com/docker/libcontainer/configs"
|
"github.com/docker/libcontainer/configs"
|
||||||
"github.com/docker/libcontainer/netlink"
|
"github.com/docker/libcontainer/netlink"
|
||||||
|
@ -234,7 +234,7 @@ func setupRlimits(config *configs.Config) error {
|
||||||
func killCgroupProcesses(m cgroups.Manager) error {
|
func killCgroupProcesses(m cgroups.Manager) error {
|
||||||
var procs []*os.Process
|
var procs []*os.Process
|
||||||
if err := m.Freeze(configs.Frozen); err != nil {
|
if err := m.Freeze(configs.Frozen); err != nil {
|
||||||
log.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
pids, err := m.GetPids()
|
pids, err := m.GetPids()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -245,16 +245,16 @@ func killCgroupProcesses(m cgroups.Manager) error {
|
||||||
if p, err := os.FindProcess(pid); err == nil {
|
if p, err := os.FindProcess(pid); err == nil {
|
||||||
procs = append(procs, p)
|
procs = append(procs, p)
|
||||||
if err := p.Kill(); err != nil {
|
if err := p.Kill(); err != nil {
|
||||||
log.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := m.Freeze(configs.Thawed); err != nil {
|
if err := m.Freeze(configs.Thawed); err != nil {
|
||||||
log.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
for _, p := range procs {
|
for _, p := range procs {
|
||||||
if _, err := p.Wait(); err != nil {
|
if _, err := p.Wait(); err != nil {
|
||||||
log.Warn(err)
|
logrus.Warn(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -204,9 +204,6 @@ func TestEnter(t *testing.T) {
|
||||||
|
|
||||||
config := newTemplateConfig(rootfs)
|
config := newTemplateConfig(rootfs)
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
defer container.Destroy()
|
defer container.Destroy()
|
||||||
|
@ -294,9 +291,6 @@ func TestProcessEnv(t *testing.T) {
|
||||||
|
|
||||||
config := newTemplateConfig(rootfs)
|
config := newTemplateConfig(rootfs)
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
defer container.Destroy()
|
defer container.Destroy()
|
||||||
|
@ -346,9 +340,6 @@ func TestProcessCaps(t *testing.T) {
|
||||||
|
|
||||||
config := newTemplateConfig(rootfs)
|
config := newTemplateConfig(rootfs)
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
defer container.Destroy()
|
defer container.Destroy()
|
||||||
|
@ -427,15 +418,12 @@ func testFreeze(t *testing.T, systemd bool) {
|
||||||
defer remove(rootfs)
|
defer remove(rootfs)
|
||||||
|
|
||||||
config := newTemplateConfig(rootfs)
|
config := newTemplateConfig(rootfs)
|
||||||
cgm := libcontainer.Cgroupfs
|
f := factory
|
||||||
if systemd {
|
if systemd {
|
||||||
cgm = libcontainer.SystemdCgroups
|
f = systemdFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, cgm)
|
container, err := f.Create("test", config)
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
defer container.Destroy()
|
defer container.Destroy()
|
||||||
|
|
||||||
|
@ -539,11 +527,6 @@ func TestContainerState(t *testing.T) {
|
||||||
{Type: configs.NEWNET},
|
{Type: configs.NEWNET},
|
||||||
})
|
})
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -595,11 +578,6 @@ func TestPassExtraFiles(t *testing.T) {
|
||||||
|
|
||||||
config := newTemplateConfig(rootfs)
|
config := newTemplateConfig(rootfs)
|
||||||
|
|
||||||
factory, err := libcontainer.New(rootfs, libcontainer.Cgroupfs)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -673,7 +651,7 @@ func TestMountCmds(t *testing.T) {
|
||||||
config := newTemplateConfig(rootfs)
|
config := newTemplateConfig(rootfs)
|
||||||
config.Mounts = append(config.Mounts, &configs.Mount{
|
config.Mounts = append(config.Mounts, &configs.Mount{
|
||||||
Source: tmpDir,
|
Source: tmpDir,
|
||||||
Destination: filepath.Join(rootfs, "tmp"),
|
Destination: "/tmp",
|
||||||
Device: "bind",
|
Device: "bind",
|
||||||
Flags: syscall.MS_BIND | syscall.MS_REC,
|
Flags: syscall.MS_BIND | syscall.MS_REC,
|
||||||
PremountCmds: []configs.Command{
|
PremountCmds: []configs.Command{
|
||||||
|
@ -686,11 +664,6 @@ func TestMountCmds(t *testing.T) {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
@ -738,9 +711,6 @@ func TestSystemProperties(t *testing.T) {
|
||||||
"kernel.shmmni": "8192",
|
"kernel.shmmni": "8192",
|
||||||
}
|
}
|
||||||
|
|
||||||
factory, err := libcontainer.New(root, libcontainer.Cgroupfs)
|
|
||||||
ok(t, err)
|
|
||||||
|
|
||||||
container, err := factory.Create("test", config)
|
container, err := factory.Create("test", config)
|
||||||
ok(t, err)
|
ok(t, err)
|
||||||
defer container.Destroy()
|
defer container.Destroy()
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package integration
|
package integration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/docker/libcontainer"
|
"github.com/docker/libcontainer"
|
||||||
|
"github.com/docker/libcontainer/cgroups/systemd"
|
||||||
_ "github.com/docker/libcontainer/nsenter"
|
_ "github.com/docker/libcontainer/nsenter"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -19,9 +21,40 @@ func init() {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
factory, err := libcontainer.New("")
|
factory, err := libcontainer.New("")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("unable to initialize for container: %s", err)
|
logrus.Fatalf("unable to initialize for container: %s", err)
|
||||||
}
|
}
|
||||||
if err := factory.StartInitialization(); err != nil {
|
if err := factory.StartInitialization(); err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
factory libcontainer.Factory
|
||||||
|
systemdFactory libcontainer.Factory
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
ret int = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
logrus.SetOutput(os.Stderr)
|
||||||
|
logrus.SetLevel(logrus.InfoLevel)
|
||||||
|
|
||||||
|
factory, err = libcontainer.New(".", libcontainer.Cgroupfs)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if systemd.UseSystemd() {
|
||||||
|
systemdFactory, err = libcontainer.New(".", libcontainer.SystemdCgroups)
|
||||||
|
if err != nil {
|
||||||
|
logrus.Error(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = m.Run()
|
||||||
|
os.Exit(ret)
|
||||||
|
}
|
||||||
|
|
|
@ -79,19 +79,13 @@ func copyBusybox(dest string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newContainer(config *configs.Config) (libcontainer.Container, error) {
|
func newContainer(config *configs.Config) (libcontainer.Container, error) {
|
||||||
cgm := libcontainer.Cgroupfs
|
f := factory
|
||||||
|
|
||||||
if config.Cgroups != nil && config.Cgroups.Slice == "system.slice" {
|
if config.Cgroups != nil && config.Cgroups.Slice == "system.slice" {
|
||||||
cgm = libcontainer.SystemdCgroups
|
f = systemdFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
factory, err := libcontainer.New(".",
|
return f.Create("testCT", config)
|
||||||
libcontainer.InitArgs(os.Args[0], "init", "--"),
|
|
||||||
cgm,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return factory.Create("testCT", config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// runContainer runs the container with the specific config and arguments
|
// runContainer runs the container with the specific config and arguments
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/docker/libcontainer"
|
"github.com/docker/libcontainer"
|
||||||
_ "github.com/docker/libcontainer/nsenter"
|
_ "github.com/docker/libcontainer/nsenter"
|
||||||
|
@ -13,7 +13,7 @@ var initCommand = cli.Command{
|
||||||
Name: "init",
|
Name: "init",
|
||||||
Usage: "runs the init process inside the namespace",
|
Usage: "runs the init process inside the namespace",
|
||||||
Action: func(context *cli.Context) {
|
Action: func(context *cli.Context) {
|
||||||
log.SetLevel(log.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
runtime.GOMAXPROCS(1)
|
runtime.GOMAXPROCS(1)
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
factory, err := libcontainer.New("")
|
factory, err := libcontainer.New("")
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,18 +29,18 @@ func main() {
|
||||||
}
|
}
|
||||||
app.Before = func(context *cli.Context) error {
|
app.Before = func(context *cli.Context) error {
|
||||||
if context.GlobalBool("debug") {
|
if context.GlobalBool("debug") {
|
||||||
log.SetLevel(log.DebugLevel)
|
logrus.SetLevel(logrus.DebugLevel)
|
||||||
}
|
}
|
||||||
if path := context.GlobalString("log-file"); path != "" {
|
if path := context.GlobalString("log-file"); path != "" {
|
||||||
f, err := os.Create(path)
|
f, err := os.Create(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
log.SetOutput(f)
|
logrus.SetOutput(f)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := app.Run(os.Args); err != nil {
|
if err := app.Run(os.Args); err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,16 +14,16 @@ var oomCommand = cli.Command{
|
||||||
Action: func(context *cli.Context) {
|
Action: func(context *cli.Context) {
|
||||||
container, err := getContainer(context)
|
container, err := getContainer(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
n, err := container.NotifyOOM()
|
n, err := container.NotifyOOM()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
for x := range n {
|
for x := range n {
|
||||||
// hack for calm down go1.4 gofmt
|
// hack for calm down go1.4 gofmt
|
||||||
_ = x
|
_ = x
|
||||||
log.Printf("OOM notification received")
|
logrus.Printf("OOM notification received")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -14,10 +14,10 @@ var pauseCommand = cli.Command{
|
||||||
Action: func(context *cli.Context) {
|
Action: func(context *cli.Context) {
|
||||||
container, err := getContainer(context)
|
container, err := getContainer(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = container.Pause(); err != nil {
|
if err = container.Pause(); err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@ var unpauseCommand = cli.Command{
|
||||||
Action: func(context *cli.Context) {
|
Action: func(context *cli.Context) {
|
||||||
container, err := getContainer(context)
|
container, err := getContainer(context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
if err = container.Resume(); err != nil {
|
if err = container.Resume(); err != nil {
|
||||||
log.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
|
@ -36,7 +36,7 @@ func loadFactory(context *cli.Context) (libcontainer.Factory, error) {
|
||||||
if systemd.UseSystemd() {
|
if systemd.UseSystemd() {
|
||||||
cgm = libcontainer.SystemdCgroups
|
cgm = libcontainer.SystemdCgroups
|
||||||
} else {
|
} else {
|
||||||
log.Warn("systemd cgroup flag passed, but systemd support for managing cgroups is not available.")
|
logrus.Warn("systemd cgroup flag passed, but systemd support for managing cgroups is not available.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return libcontainer.New(context.GlobalString("root"), cgm)
|
return libcontainer.New(context.GlobalString("root"), cgm)
|
||||||
|
|
Loading…
Reference in a new issue