Пример #1
0
func (p *provider) ProvideContainer(spec linux_backend.LinuxContainerSpec) linux_backend.Container {
	cgroupReader := &cgroups_manager.LinuxCgroupReader{
		Path: p.sysconfig.CgroupNodeFilePath,
	}

	cgroupsManager := cgroups_manager.New(p.sysconfig.CgroupPath, spec.ID, cgroupReader)

	oomWatcher := linux_container.NewOomNotifier(
		p.runner, spec.ContainerPath, cgroupsManager,
	)

	return linux_container.NewLinuxContainer(
		spec,
		p.portPool,
		p.runner,
		cgroupsManager,
		p.quotaManager,
		bandwidth_manager.New(spec.ContainerPath, spec.ID, p.runner),
		process_tracker.New(spec.ContainerPath, p.runner),
		p.ProvideFilter(spec.ID),
		p.ipTablesMgr,
		devices.Link{Name: p.sysconfig.NetworkInterfacePrefix + spec.ID + "-0"},
		oomWatcher,
		p.log.Session("container", lager.Data{"handle": spec.Handle}),
	)
}
Пример #2
0
		)
	})

	JustBeforeEach(func() {
		container = linux_container.NewLinuxContainer(
			linux_backend.LinuxContainerSpec{
				ID:                  "some-id",
				ContainerPath:       containerDir,
				ContainerRootFSPath: "some-volume-path",
				Resources:           containerResources,
				ContainerSpec: garden.ContainerSpec{
					Handle:    "some-handle",
					GraceTime: time.Second * 1,
				},
			},
			fake_port_pool.New(1000),
			fakeRunner,
			fakeCgroups,
			fakeQuotaManager,
			fakeBandwidthManager,
			new(fake_process_tracker.FakeProcessTracker),
			new(networkFakes.FakeFilter),
			new(fake_iptables_manager.FakeIPTablesManager),
			new(fake_network_statisticser.FakeNetworkStatisticser),
			fakeOomWatcher,
			lagertest.NewTestLogger("linux-container-limits-test"),
		)
	})

	Describe("Limiting bandwidth", func() {
		limits := garden.BandwidthLimits{
		}
	})

	JustBeforeEach(func() {
		container = linux_container.NewLinuxContainer(
			linux_backend.LinuxContainerSpec{
				ID:                  "some-id",
				ContainerPath:       containerDir,
				ContainerRootFSPath: "some-volume-path",
				Resources:           containerResources,
				State:               linux_backend.StateBorn,
				ContainerSpec: garden.ContainerSpec{
					Handle:     "some-handle",
					GraceTime:  time.Second * 1,
					Properties: containerProps,
				},
			},
			fakePortPool,
			fakeRunner,
			fakeCgroups,
			fakeQuotaManager,
			fakeBandwidthManager,
			fakeProcessTracker,
			fakeFilter,
			new(fake_network_statisticser.FakeNetworkStatisticser),
			fakeOomWatcher,
			lagertest.NewTestLogger("linux-container-limits-test"),
		)
	})

	It("sets the container ID", func() {
		Expect(container.ID()).To(Equal("some-id"))
Пример #4
0
	})

	JustBeforeEach(func() {
		logger = lagertest.NewTestLogger("linux-container-limits-test")
		container = linux_container.NewLinuxContainer(
			linux_backend.LinuxContainerSpec{
				ID:                  "some-id",
				ContainerPath:       containerDir,
				ContainerRootFSPath: "some-volume-path",
				Resources:           containerResources,
				ContainerSpec: garden.ContainerSpec{
					Handle:    "some-handle",
					GraceTime: time.Second * 1,
					Env:       []string{"env1=env1Value", "env2=env2Value"},
				},
				Version: containerVersion,
			},
			fake_port_pool.New(1000),
			fake_command_runner.New(),
			new(fake_cgroups_manager.FakeCgroupsManager),
			new(fake_quota_manager.FakeQuotaManager),
			fake_bandwidth_manager.New(),
			fakeProcessTracker,
			new(networkFakes.FakeFilter),
			new(fake_network_statisticser.FakeNetworkStatisticser),
			new(fake_watcher.FakeWatcher),
			logger,
		)
	})

	Describe("Running", func() {
		It("runs the /bin/bash via wsh with the given script as the input, and rlimits in env", func() {