Example #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})
}
Example #2
0
		It("returns a bundle with the resources added to the runtime spec", func() {
			Expect(returnedBundle.Resources()).To(Equal(&specs.LinuxResources{DisableOOMKiller: &t}))
		})

		It("does not modify the original bundle", func() {
			Expect(returnedBundle).NotTo(Equal(initialBundle))
			Expect(initialBundle.Resources()).To(BeNil())
		})
	})

	Describe("WithCPUShares", func() {
		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() {