Skip to content

Commit 81b840c

Browse files
committed
Merge branch 'quota-management' into quota-management-fix-generic-items-cleanup
2 parents de0f6bd + f9ef292 commit 81b840c

File tree

4 files changed

+174
-9
lines changed

4 files changed

+174
-9
lines changed

CONTROLLER_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.29.41
1+
1.29.42

pkg/controller/queuejobresources/genericresource/genericresource.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -515,21 +515,25 @@ func GetResources(awr *arbv1.AppWrapperGenericResource) (resource *clusterstatea
515515
var err error
516516
err = nil
517517
if awr.GenericTemplate.Raw != nil {
518+
if len(awr.CustomPodResources) > 0 {
519+
podresources := awr.CustomPodResources
520+
for _, item := range podresources {
521+
res := getPodResources(item)
522+
totalresource = totalresource.Add(res)
523+
}
524+
klog.V(4).Infof("[GetResources] Requested total allocation resource from custompodresources `%v`.\n", totalresource)
525+
return totalresource, err
526+
}
518527
hasContainer, replicas, containers := hasFields(awr.GenericTemplate)
519528
if hasContainer {
520529
for _, item := range containers {
521530
res := getContainerResources(item, replicas)
522531
totalresource = totalresource.Add(res)
523532
}
524-
klog.V(8).Infof("[GetResources] Requested total allocation resource from containers `%v`.\n", totalresource)
525-
} else {
526-
podresources := awr.CustomPodResources
527-
for _, item := range podresources {
528-
res := getPodResources(item)
529-
totalresource = totalresource.Add(res)
530-
}
531-
klog.V(8).Infof("[GetResources] Requested total allocation resource from pods `%v`.\n", totalresource)
533+
klog.V(4).Infof("[GetResources] Requested total allocation resource from containers `%v`.\n", totalresource)
534+
return totalresource, err
532535
}
536+
533537
} else {
534538
err = fmt.Errorf("generic template raw object is not defined (nil)")
535539
}

test/e2e/queue.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,79 @@ var _ = Describe("AppWrapper E2E Test", func() {
315315

316316
})
317317

318+
It("MCAD Custom Pod Resources Test", func() {
319+
fmt.Fprintf(os.Stdout, "[e2e] MCAD Custom Pod Resources Test - Started.\n")
320+
context := initTestContext()
321+
var appwrappers []*arbv1.AppWrapper
322+
appwrappersPtr := &appwrappers
323+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
324+
325+
// This should fit on cluster with customPodResources matching deployment resource demands so AW pods are created
326+
aw := createGenericDeploymentCustomPodResourcesWithCPUAW(
327+
context, "aw-deployment-2-550-vs-550-cpu", "550m", "550m", 2)
328+
329+
appwrappers = append(appwrappers, aw)
330+
331+
err := waitAWAnyPodsExists(context, aw)
332+
Expect(err).NotTo(HaveOccurred())
333+
334+
err = waitAWPodsReady(context, aw)
335+
Expect(err).NotTo(HaveOccurred())
336+
})
337+
338+
339+
It("MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Not Queuing Test", func() {
340+
fmt.Fprintf(os.Stdout, "[e2e] MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Not Queuing Test - Started.\n")
341+
context := initTestContext()
342+
var appwrappers []*arbv1.AppWrapper
343+
appwrappersPtr := &appwrappers
344+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
345+
346+
// This should fill up the worker node and most of the master node
347+
aw := createDeploymentAWwith550CPU(context, "aw-deployment-2-550cpu")
348+
appwrappers = append(appwrappers, aw)
349+
350+
err := waitAWPodsReady(context, aw)
351+
Expect(err).NotTo(HaveOccurred())
352+
353+
// This should not fit on cluster but customPodResources is incorrect so AW pods are created
354+
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
355+
context, "aw-deployment-2-425-vs-426-cpu", "425m", "426m", 2)
356+
357+
appwrappers = append(appwrappers, aw2)
358+
359+
err = waitAWAnyPodsExists(context, aw2)
360+
Expect(err).NotTo(HaveOccurred())
361+
362+
err = waitAWPodsReady(context, aw2)
363+
Expect(err).To(HaveOccurred())
364+
})
365+
366+
It("MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Queuing Test 2", func() {
367+
fmt.Fprintf(os.Stdout, "[e2e] MCAD Bad Custom Pod Resources vs. Deployment Pod Resource Queuing Test 2 - Started.\n")
368+
context := initTestContext()
369+
var appwrappers []*arbv1.AppWrapper
370+
appwrappersPtr := &appwrappers
371+
defer cleanupTestObjectsPtr(context, appwrappersPtr)
372+
373+
// This should fill up the worker node and most of the master node
374+
aw := createDeploymentAWwith550CPU(context, "aw-deployment-2-550cpu")
375+
appwrappers = append(appwrappers, aw)
376+
377+
err := waitAWPodsReady(context, aw)
378+
Expect(err).NotTo(HaveOccurred())
379+
380+
// This should fit on cluster but customPodResources is incorrect so AW pods are not created
381+
aw2 := createGenericDeploymentCustomPodResourcesWithCPUAW(
382+
context, "aw-deployment-2-426-vs-425-cpu", "426m", "425m", 2)
383+
384+
appwrappers = append(appwrappers, aw2)
385+
386+
err = waitAWAnyPodsExists(context, aw2)
387+
Expect(err).To(HaveOccurred())
388+
389+
})
390+
318391
It("MCAD CPU Accounting Queuing Test", func() {
319392
fmt.Fprintf(os.Stdout, "[e2e] MCAD CPU Accounting Queuing Test - Started.\n")
320393
context := initTestContext()

test/e2e/util.go

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1596,6 +1596,94 @@ func createGenericDeploymentWithCPUAW(context *context, name string, cpuDemand s
15961596
return appwrapper
15971597
}
15981598

1599+
func createGenericDeploymentCustomPodResourcesWithCPUAW(context *context, name string, customPodCpuDemand string, cpuDemand string, replicas int) *arbv1.AppWrapper {
1600+
rb := []byte(fmt.Sprintf(`{
1601+
"apiVersion": "apps/v1",
1602+
"kind": "Deployment",
1603+
"metadata": {
1604+
"name": "%s",
1605+
"namespace": "test",
1606+
"labels": {
1607+
"app": "%s"
1608+
}
1609+
},
1610+
"spec": {
1611+
"replicas": %d,
1612+
"selector": {
1613+
"matchLabels": {
1614+
"app": "%s"
1615+
}
1616+
},
1617+
"template": {
1618+
"metadata": {
1619+
"labels": {
1620+
"app": "%s"
1621+
},
1622+
"annotations": {
1623+
"appwrapper.mcad.ibm.com/appwrapper-name": "%s"
1624+
}
1625+
},
1626+
"spec": {
1627+
"containers": [
1628+
{
1629+
"name": "%s",
1630+
"image": "k8s.gcr.io/echoserver:1.4",
1631+
"resources": {
1632+
"requests": {
1633+
"cpu": "%s"
1634+
}
1635+
},
1636+
"ports": [
1637+
{
1638+
"containerPort": 80
1639+
}
1640+
]
1641+
}
1642+
]
1643+
}
1644+
}
1645+
}} `, name, name, replicas, name, name, name, name, cpuDemand))
1646+
1647+
var schedSpecMin int = replicas
1648+
var customCpuResource = v1.ResourceList{"cpu": resource.MustParse(customPodCpuDemand)}
1649+
1650+
aw := &arbv1.AppWrapper{
1651+
ObjectMeta: metav1.ObjectMeta{
1652+
Name: name,
1653+
Namespace: context.namespace,
1654+
},
1655+
Spec: arbv1.AppWrapperSpec{
1656+
SchedSpec: arbv1.SchedulingSpecTemplate{
1657+
MinAvailable: schedSpecMin,
1658+
},
1659+
AggrResources: arbv1.AppWrapperResourceList{
1660+
GenericItems: []arbv1.AppWrapperGenericResource{
1661+
{
1662+
ObjectMeta: metav1.ObjectMeta{
1663+
Name: fmt.Sprintf("%s-%s", name, "item1"),
1664+
Namespace: context.namespace,
1665+
},
1666+
CustomPodResources: []arbv1.CustomPodResourceTemplate{
1667+
{
1668+
Replicas: replicas,
1669+
Requests: customCpuResource,
1670+
},
1671+
},
1672+
GenericTemplate: runtime.RawExtension{
1673+
Raw: rb,
1674+
},
1675+
},
1676+
},
1677+
},
1678+
},
1679+
}
1680+
1681+
appwrapper, err := context.karclient.ArbV1().AppWrappers(context.namespace).Create(aw)
1682+
Expect(err).NotTo(HaveOccurred())
1683+
1684+
return appwrapper
1685+
}
1686+
15991687
func createNamespaceAW(context *context, name string) *arbv1.AppWrapper {
16001688
rb := []byte(`{"apiVersion": "v1",
16011689
"kind": "Namespace",

0 commit comments

Comments
 (0)