Skip to content
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

improve: continue allocating if remain tasks is more than job's minMember #3430

Merged
merged 4 commits into from
Jul 15, 2024

Conversation

lowang-bh
Copy link
Member

@lowang-bh lowang-bh commented Apr 21, 2024

As PR #1459 has supported minAvailable at task level.

#3057 has improved and fixed the minResource calculation for a volcano job.
This PR continue to improve and fix the scheduling.

Consider this scene:
part of pods of a job is not schedulable, and left pods are schedulable, and the number can meet up the condition of min member.
example: cluster has only 4GPU and enough CP/MEM, a job with 1ps + 8worker, each worker request 1GPU and has higher priority than ps. So workers will be scheduled first and failed at 5th worker. After that, job will be failed scheduling and break out from allocate.

So this pr fix this issue: if allocated pod less than minMember and tasks are not used up, will continue on, untill the number of remained tasks can not meet up the condition of min member

commit 1: continue allocating and testcases about the feature change
commit 2: use string type to replace the taskID type, which indicate a role spec of each task in a job
commit 3: consider job's each task's min member when check if it can continue on allocating
commit 4: parse and store task spec in taskInfo, so that it doesn't need to parse it everywhere and whenerver it is used.
And add pre-check if task has fit error so as to save predicating time and avoid the useless computing. Testing with a 100master+100worker job has no obvious latancy comparing without this PR.

An Example Yaml Without Priority setting

with the following job yaml on a cluster with available CPU=10

apiVersion: batch.volcano.sh/v1alpha1
kind: Job
metadata:
  name: job5
spec:
  schedulerName: volcano
  minAvailable: 3
  queue: default
  tasks:
    - replicas: 2
      minAvailable: 1
      name: "master"
      template:
        spec:
          containers:
            - image: nginx:latest
              name: nginx
              resources:
                requests:
                  cpu: "4"
                  memory: "50Mi"
          restartPolicy: OnFailure
    - replicas: 2
      minAvailable: 2
      name: "work"
      template:
        spec:
          containers:
            - image: nginx:latest
              name: nginx
              resources:
                requests:
                  cpu: "3"
                  memory: "100Mi"
          restartPolicy: OnFailure
Test Example Yaml

with the following job yaml on a cluster with available CPU<4

apiVersion: batch.volcano.sh/v1alpha1
kind: Job
metadata:
  name: my-apps
spec:
  schedulerName: volcano
  minAvailable: 2
  tasks:
    - replicas: 2
      name: "web"
      minAvailable: 1
      template:
        spec:
          containers:
            - image: nginx:1.14.2
              name: web
              resources:
                requests:
                  cpu: "1000m"
                  memory: "100Mi"
          restartPolicy: OnFailure
    - replicas: 2
      minAvailable: 1
      name: "server"
      template:
        spec:
          containers:
            - image: nginx:1.14.2
              name: server
              resources:
                requests:
                  cpu: "2000m"
                  memory: "100Mi"
          restartPolicy: OnFailure
          priorityClassName: high-priority

without this pr on master branch

image image

with this pr

image image

@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 21, 2024
@lowang-bh
Copy link
Member Author

/assign @Monokaix @hwdef @william-wang

@lowang-bh lowang-bh changed the title improve: continue allocating if allocated pod less than minMember and… improve: continue allocating if left tasks is more than job's minMember Apr 21, 2024
@lowang-bh lowang-bh changed the title improve: continue allocating if left tasks is more than job's minMember improve: continue allocating if remain tasks is more than job's minMember Apr 21, 2024
Copy link
Member

@hwdef hwdef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this PR does two things. But use one commit

@lowang-bh
Copy link
Member Author

It looks like this PR does two things. But use one commit

Have splited them into two commits.

@lowang-bh
Copy link
Member Author

@Monokaix @hwdef @wangyang0616 @william-wang please help to review it. thanks.

@hwdef
Copy link
Member

hwdef commented May 10, 2024

I think the others are fine

@lowang-bh lowang-bh force-pushed the fixAllocate branch 2 times, most recently from bfe1bb4 to c4c8c74 Compare May 13, 2024 13:52
@volcano-sh-bot volcano-sh-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 21, 2024
@volcano-sh-bot volcano-sh-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 21, 2024
@lowang-bh lowang-bh closed this May 22, 2024
@lowang-bh lowang-bh reopened this May 22, 2024
@Monokaix
Copy link
Member

The are 4 commits but the description has 2 commit.

@volcano-sh-bot volcano-sh-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 15, 2024
… tasks are not used up

Signed-off-by: lowang-bh <lhui_wang@163.com>
…tring and has nothing to do with taskID

Signed-off-by: lowang-bh <lhui_wang@163.com>
Signed-off-by: lowang-bh <lhui_wang@163.com>

rebase from master

Signed-off-by: lowang-bh <lhui_wang@163.com>
@volcano-sh-bot volcano-sh-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 15, 2024
@Monokaix
Copy link
Member

Monokaix commented Jun 19, 2024

A little doubt, in what case will a work pod has higher priority than ps? And what if pods in a vcjob have the same priority?

@lowang-bh
Copy link
Member Author

A little doubt, in what case will a work pod has higher priority than ps? And what if pods in a vcjob have the same priority?

worker with GPU request, can have a higher priority, so as to allocate gpu pod first.

@lowang-bh
Copy link
Member Author

And what if pods in a vcjob have the same priority?

With no priority setting, the task order will be default compare stragety at

func CompareTask(lv, rv *api.TaskInfo) bool {
lStr := GetPodIndexUnderTask(lv.Pod)
rStr := GetPodIndexUnderTask(rv.Pod)
lIndex, lErr := strconv.Atoi(lStr)
rIndex, rErr := strconv.Atoi(rStr)
if lErr != nil || rErr != nil || lIndex == rIndex {
if lv.Pod.CreationTimestamp.Equal(&rv.Pod.CreationTimestamp) {
return lv.UID < rv.UID
}
return lv.Pod.CreationTimestamp.Before(&rv.Pod.CreationTimestamp)
}
if lIndex > rIndex {
return false
}
return true
}

With Given Example Yaml Without Priority setting

before

image

after this pr

image

@Monokaix
Copy link
Member

/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2024
Copy link
Member

@hwdef hwdef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

… fit error so as to save predicating time

fix comments: use taskRole to store the value of 'volcano.sh/task-spec' in taskInfo

Signed-off-by: lowang-bh <lhui_wang@163.com>

Signed-off-by: lowang-bh <lhui_wang@163.com>

Signed-off-by: lowang-bh <lhui_wang@163.com>
@volcano-sh-bot volcano-sh-bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 13, 2024
Copy link
Member

@william-wang william-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Jul 15, 2024
@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: william-wang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 15, 2024
@volcano-sh-bot volcano-sh-bot merged commit 85494a9 into volcano-sh:master Jul 15, 2024
14 checks passed
@lowang-bh lowang-bh deleted the fixAllocate branch July 15, 2024 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants