Skip to content

Commit

Permalink
feat: restartPolicy pointer
Browse files Browse the repository at this point in the history
Signed-off-by: sadath-12 <[email protected]>
  • Loading branch information
sadath-12 authored and jonathan-innis committed Oct 18, 2023
1 parent c8e52a4 commit 38c58b8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 58 deletions.
43 changes: 18 additions & 25 deletions pkg/controllers/provisioning/nodepool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})
})
Context("Resource Calculations", func() {
always := v1.ContainerRestartPolicyAlways

It("should schedule based on the sum of containers and sidecarContainers", func() {
pod := test.Pod(test.PodOptions{
Expand All @@ -1482,7 +1481,7 @@ var _ = Describe("NodePool/Provisioning", func() {

InitContainers: []v1.Container{
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("4"), v1.ResourceMemory: resource.MustParse("2Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand Down Expand Up @@ -1514,7 +1513,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("3"), v1.ResourceMemory: resource.MustParse("3Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1528,7 +1527,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})

It("should schedule based on the max resource requests of containers and initContainers with sidecarContainers for order of type1", func() {
always := v1.ContainerRestartPolicyAlways

pod := test.Pod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand All @@ -1538,7 +1536,7 @@ var _ = Describe("NodePool/Provisioning", func() {

InitContainers: []v1.Container{
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("4"), v1.ResourceMemory: resource.MustParse("2Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1559,7 +1557,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})

It("should schedule based on the max resource requests of containers and initContainers with sidecarContainers for order of type2", func() {
always := v1.ContainerRestartPolicyAlways

pod := test.Pod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand All @@ -1569,7 +1566,7 @@ var _ = Describe("NodePool/Provisioning", func() {

InitContainers: []v1.Container{
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("4"), v1.ResourceMemory: resource.MustParse("2Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1590,7 +1587,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})

It("should schedule based on the max resource requests of containers and initContainers with sidecarContainers for order of type3", func() {
always := v1.ContainerRestartPolicyAlways

pod := test.Pod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand All @@ -1600,28 +1596,28 @@ var _ = Describe("NodePool/Provisioning", func() {

InitContainers: []v1.Container{
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("2"), v1.ResourceMemory: resource.MustParse("2Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("1Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("3"), v1.ResourceMemory: resource.MustParse("3Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("5"), v1.ResourceMemory: resource.MustParse("5Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1642,7 +1638,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})

It("should schedule based on the max resource requests of containers and initContainers with sidecarContainers for order of type4", func() {
always := v1.ContainerRestartPolicyAlways

pod := test.Pod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand All @@ -1652,28 +1647,28 @@ var _ = Describe("NodePool/Provisioning", func() {

InitContainers: []v1.Container{
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("2"), v1.ResourceMemory: resource.MustParse("2Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("1Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("3"), v1.ResourceMemory: resource.MustParse("3Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("5"), v1.ResourceMemory: resource.MustParse("5Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1694,7 +1689,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})

It("should schedule based on the max resource requests of containers and initContainers with sidecarContainers for order of type5", func() {
always := v1.ContainerRestartPolicyAlways

pod := test.Pod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand All @@ -1710,7 +1704,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("1Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1730,7 +1724,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("5"), v1.ResourceMemory: resource.MustParse("5Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1749,7 +1743,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("1Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1764,7 +1758,6 @@ var _ = Describe("NodePool/Provisioning", func() {
})

It("should schedule based on the max resource requests of containers and initContainers with sidecarContainers for order of type6", func() {
always := v1.ContainerRestartPolicyAlways

pod := test.Pod(test.PodOptions{
ResourceRequirements: v1.ResourceRequirements{
Expand All @@ -1780,7 +1773,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("1Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1800,7 +1793,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("5"), v1.ResourceMemory: resource.MustParse("5Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand All @@ -1819,7 +1812,7 @@ var _ = Describe("NodePool/Provisioning", func() {
},
},
{
RestartPolicy: &always,
RestartPolicy: lo.ToPtr(v1.ContainerRestartPolicyAlways),
Resources: v1.ResourceRequirements{
Limits: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1"), v1.ResourceMemory: resource.MustParse("1Gi")},
Requests: v1.ResourceList{v1.ResourceCPU: resource.MustParse("1")},
Expand Down
Loading

0 comments on commit 38c58b8

Please sign in to comment.