Skip to content

fix acc for AWs that never completes but genericItem completes #460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions pkg/controller/queuejob/queuejob_controller_ex.go
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,11 @@ func (qjm *XController) getAggregatedAvailableResourcesPriority(unallocatedClust
klog.V(11).Infof("[getAggAvaiResPri] %s: Skipping adjustments for %s since it is the job being processed.", time.Now().String(), value.Name)
continue
} else if !value.Status.CanRun {
totalResource := qjm.addTotalSnapshotResourcesConsumedByAw(value.Status.TotalGPU, value.Status.TotalCPU, value.Status.TotalMemory)
klog.V(6).Infof("[getAggAvaiResPri] %s: AW %s cannot run, adding any dangling pod resources %v while it being preempted.", time.Now().String(), value.Name, totalResource)
preemptable = preemptable.Add(totalResource)
// canRun is false when AW completes or it is preempted
// when preempted AW is cleanedup and resources will be released by preempt thread
// when AW is completed cluster state will reflect available resources
// in both cases we do not account for resources.
klog.V(6).Infof("[getAggAvaiResPri] %s: AW %s cannot run, so not accounting resoources", time.Now().String(), value.Name)
continue
} else if value.Status.SystemPriority < targetpr {
// Dispatcher Mode: Ensure this job is part of the target cluster
Expand All @@ -929,7 +931,13 @@ func (qjm *XController) getAggregatedAvailableResourcesPriority(unallocatedClust
klog.V(10).Infof("[getAggAvaiResPri] %s: Added %s to candidate preemptable job with priority %f.", time.Now().String(), value.Name, value.Status.SystemPriority)
}

err := qjm.qjobResControls[arbv1.ResourceTypePod].UpdateQueueJobStatus(value)
if err != nil {
klog.Warningf("[getAggAvaiResPri] Error updating pod status counts for AppWrapper job: %s, err=%+v", value.Name, err)
}

totalResource := qjm.addTotalSnapshotResourcesConsumedByAw(value.Status.TotalGPU, value.Status.TotalCPU, value.Status.TotalMemory)
klog.V(10).Infof("[getAggAvaiResPri] total resources consumed by Appwrapper %v when lower priority compared to target are %v", value.Name, totalResource)
preemptable = preemptable.Add(totalResource)
klog.V(6).Infof("[getAggAvaiResPri] %s proirity %v is lower target priority %v reclaiming total preemptable resources %v", value.Name, value.Status.SystemPriority, targetpr, totalResource)
continue
Expand All @@ -953,13 +961,19 @@ func (qjm *XController) getAggregatedAvailableResourcesPriority(unallocatedClust
klog.V(10).Infof("[getAggAvaiResPri] Subtract all resources %+v in genericItem=%T for job %s which can-run is set to: %v but state is still pending.", qjv, genericItem, value.Name, value.Status.CanRun)
}

err := qjm.qjobResControls[arbv1.ResourceTypePod].UpdateQueueJobStatus(value)
if err != nil {
klog.Warningf("[getAggAvaiResPri] Error updating pod status counts for AppWrapper job: %s, err=%+v", value.Name, err)
}

totalResource := qjm.addTotalSnapshotResourcesConsumedByAw(value.Status.TotalGPU, value.Status.TotalCPU, value.Status.TotalMemory)
delta, err := qjv.NonNegSub(totalResource)
klog.V(6).Infof("[getAggAvaiResPri] total resources consumed by Appwrapper %v when CanRun are %v", value.Name, totalResource)
pending, err = qjv.NonNegSub(totalResource)
if err != nil {
klog.Warningf("[getAggAvaiResPri] Subtraction of resources failed, adding entire appwrapper resoources %v, %v", qjv, err)
pending = qjv
}
pending = pending.Add(delta)
klog.V(6).Infof("[getAggAvaiResPri] The value of pending is %v", pending)
continue
} else {
//Do nothing
Expand Down Expand Up @@ -1568,7 +1582,7 @@ func (cc *XController) Run(stopCh chan struct{}) {
cc.cache.Run(stopCh)

// go wait.Until(cc.ScheduleNext, 2*time.Second, stopCh)
go wait.Until(cc.ScheduleNext, 0, stopCh)
go wait.Until(cc.ScheduleNext, 2*time.Second, stopCh)
// start preempt thread based on preemption of pods

// TODO - scheduleNext...Job....
Expand Down
22 changes: 13 additions & 9 deletions pkg/controller/queuejobresources/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,22 +243,26 @@ func (qjrPod *QueueJobResPod) UpdateQueueJobStatus(queuejob *arbv1.AppWrapper) e
}

running := int32(queuejobresources.FilterPods(pods, v1.PodRunning))
totalResourcesConsumed := queuejobresources.GetPodResourcesByPhase(v1.PodRunning, pods)
podPhases := []v1.PodPhase{v1.PodRunning, v1.PodSucceeded}
totalResourcesConsumedForPodPhases := clusterstateapi.EmptyResource()
for _, phase := range podPhases {
totalResourcesConsumedForPodPhases.Add(queuejobresources.GetPodResourcesByPhase(phase, pods))
}
pending := int32(queuejobresources.FilterPods(pods, v1.PodPending))
succeeded := int32(queuejobresources.FilterPods(pods, v1.PodSucceeded))
failed := int32(queuejobresources.FilterPods(pods, v1.PodFailed))
podsConditionMap := queuejobresources.PendingPodsFailedSchd(pods)
klog.V(10).Infof("[UpdateQueueJobStatus] There are %d pods of AppWrapper %s: pending %d, running %d, succeeded %d, failed %d, pendingpodsfailedschd %d",
len(pods), queuejob.Name, pending, running, succeeded, failed, len(podsConditionMap))
klog.V(10).Infof("[UpdateQueueJobStatus] There are %d pods of AppWrapper %s: pending %d, running %d, succeeded %d, failed %d, pendingpodsfailedschd %d, total resource consumed %v",
len(pods), queuejob.Name, pending, running, succeeded, failed, len(podsConditionMap), totalResourcesConsumedForPodPhases)

queuejob.Status.Pending = pending
queuejob.Status.Running = running
queuejob.Status.Succeeded = succeeded
queuejob.Status.Failed = failed
//Total resources by all running pods
queuejob.Status.TotalGPU = totalResourcesConsumed.GPU
queuejob.Status.TotalCPU = totalResourcesConsumed.MilliCPU
queuejob.Status.TotalMemory = totalResourcesConsumed.Memory
queuejob.Status.TotalGPU = totalResourcesConsumedForPodPhases.GPU
queuejob.Status.TotalCPU = totalResourcesConsumedForPodPhases.MilliCPU
queuejob.Status.TotalMemory = totalResourcesConsumedForPodPhases.Memory

queuejob.Status.PendingPodConditions = nil
for podName, cond := range podsConditionMap {
Expand Down Expand Up @@ -623,7 +627,7 @@ func (qjrPod *QueueJobResPod) createQueueJobPod(qj *arbv1.AppWrapper, ix int32,
if tmpl == nil {
tmpl = make(map[string]string)
}

tmpl[queueJobName] = qj.Name

// Include pre-defined metadata info, e.g. annotations
Expand All @@ -634,12 +638,12 @@ func (qjrPod *QueueJobResPod) createQueueJobPod(qj *arbv1.AppWrapper, ix int32,
templateObjMetadata.SetNamespace(qj.Namespace)
templateObjMetadata.SetOwnerReferences([]metav1.OwnerReference{
*metav1.NewControllerRef(qj, queueJobKind),
},)
})
templateObjMetadata.SetLabels(tmpl)

return &v1.Pod{
ObjectMeta: templateObjMetadata,
Spec: templateCopy.Spec,
Spec: templateCopy.Spec,
}
}

Expand Down
15 changes: 10 additions & 5 deletions test/e2e/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ var _ = Describe("AppWrapper E2E Test", func() {

// Using quite mode due to creating of pods in earlier step.
err = waitAWReadyQuiet(context, aw2)
fmt.Fprintf(os.Stdout, "The error is %v", err)
Expect(err).NotTo(HaveOccurred())
})

Expand All @@ -118,7 +119,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
// This should fill up the worker node and most of the master node
aw := createDeploymentAWwith550CPU(context, appendRandomString("aw-deployment-2-550cpu"))
appwrappers = append(appwrappers, aw)

time.Sleep(2 * time.Minute)
err := waitAWPodsReady(context, aw)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -136,6 +137,7 @@ var _ = Describe("AppWrapper E2E Test", func() {

// Since preemption takes some time, increasing timeout wait time to 2 minutes
err = waitAWPodsExists(context, aw3, 120000*time.Millisecond)
fmt.Fprintf(os.Stdout, "[e2e] The error is %v", err)
Expect(err).NotTo(HaveOccurred())
})

Expand Down Expand Up @@ -425,7 +427,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
// This should fill up the worker node and most of the master node
aw := createDeploymentAWwith550CPU(context, appendRandomString("aw-deployment-2-550cpu"))
appwrappers = append(appwrappers, aw)

time.Sleep(1 * time.Minute)
err := waitAWPodsReady(context, aw)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -436,6 +438,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
appwrappers = append(appwrappers, aw2)

err = waitAWAnyPodsExists(context, aw2)
fmt.Fprintf(os.Stdout, "The error is %v", err)
Expect(err).NotTo(HaveOccurred())

err = waitAWPodsPending(context, aw2)
Expand All @@ -455,7 +458,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
// Make sure they are running
err = waitAWPodsReady(context, aw3)
Expect(err).NotTo(HaveOccurred())

time.Sleep(2 * time.Minute)
// Make sure pods from AW aw-deployment-1-700-cpu above do not exist proving preemption
err = waitAWAnyPodsExists(context, aw2)
Expect(err).To(HaveOccurred())
Expand All @@ -482,6 +485,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
appwrappers = append(appwrappers, aw2)

err = waitAWAnyPodsExists(context, aw2)
fmt.Fprintf(os.Stdout, "the error is %v", err)
Expect(err).NotTo(HaveOccurred())

err = waitAWPodsReady(context, aw2)
Expand All @@ -498,6 +502,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
// This should fill up the worker node and most of the master node
aw := createDeploymentAWwith550CPU(context, appendRandomString("aw-deployment-2-550cpu"))
appwrappers = append(appwrappers, aw)
time.Sleep(1 * time.Minute)

err := waitAWPodsReady(context, aw)
Expect(err).NotTo(HaveOccurred())
Expand All @@ -507,7 +512,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
context, appendRandomString("aw-deployment-2-426-vs-425-cpu"), "426m", "425m", 2, 60)

appwrappers = append(appwrappers, aw2)

time.Sleep(1 * time.Minute)
err = waitAWAnyPodsExists(context, aw2)
Expect(err).To(HaveOccurred())

Expand Down Expand Up @@ -664,7 +669,7 @@ var _ = Describe("AppWrapper E2E Test", func() {
// This should fill up the worker node and most of the master node
aw := createDeploymentAWwith550CPU(context, appendRandomString("aw-deployment-2-550cpu"))
appwrappers = append(appwrappers, aw)

time.Sleep(1 * time.Minute)
err := waitAWPodsReady(context, aw)
Expect(err).NotTo(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ func waitAWPending(ctx *context, aw *arbv1.AppWrapper) error {
}

func waitAWPodsReadyEx(ctx *context, aw *arbv1.AppWrapper, taskNum int, quite bool) error {
return wait.Poll(100*time.Millisecond, ninetySeconds, awPodPhase(ctx, aw,
return wait.Poll(100*time.Millisecond, threeHundredSeconds, awPodPhase(ctx, aw,
[]v1.PodPhase{v1.PodRunning, v1.PodSucceeded}, taskNum, quite))
}

Expand Down