Exemplo n.º 1
0
func (l Limits) Apply(bndl goci.Bndl, spec gardener.DesiredContainerSpec) goci.Bndl {
	limit := uint64(spec.Limits.Memory.LimitInBytes)
	bndl = bndl.WithMemoryLimit(specs.LinuxMemory{Limit: &limit, Swap: &limit})
	shares := uint64(spec.Limits.CPU.LimitInShares)
	bndl = bndl.WithCPUShares(specs.LinuxCPU{Shares: &shares})
	pids := int64(spec.Limits.Pid.Max)
	return bndl.WithPidLimit(specs.LinuxPids{Limit: pids})
}
Exemplo n.º 2
0
		var shares uint64 = 10

		BeforeEach(func() {
			returnedBundle = initialBundle.WithCPUShares(specs.LinuxCPU{Shares: &shares})
		})

		It("returns a bundle with the cpu shares added to the runtime spec", func() {
			Expect(returnedBundle.Resources().CPU).To(Equal(&specs.LinuxCPU{Shares: &shares}))
		})
	})

	Describe("WithPidLimit", func() {
		var pidLimit int64 = 10

		BeforeEach(func() {
			returnedBundle = initialBundle.WithPidLimit(specs.LinuxPids{Limit: pidLimit})
		})

		It("returns a bundle with the pid limit added to the runtime spec", func() {
			Expect(returnedBundle.Resources().Pids).To(Equal(&specs.LinuxPids{Limit: pidLimit}))
		})
	})

	Describe("WithNamespace", func() {
		It("does not change any namespaces other than the one with the given type", func() {
			colin := specs.LinuxNamespace{Type: "colin", Path: ""}
			potato := specs.LinuxNamespace{Type: "potato", Path: "pan"}

			initialBundle = initialBundle.WithNamespace(colin)
			returnedBundle = initialBundle.WithNamespace(potato)
			Expect(returnedBundle.Namespaces()).To(ConsistOf(colin, potato))