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

calc PGMinResources for Resources.Limits #309

Merged
merged 1 commit into from
Jul 9, 2019
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
2 changes: 1 addition & 1 deletion pkg/controllers/job/job_controller_actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ func (cc *Controller) calcPGMinResources(job *vkv1.Job) *v1.ResourceList {
}
podCnt++
for _, c := range task.Template.Spec.Containers {
addResourceList(minAvailableTasksRes, c.Resources.Requests)
addResourceList(minAvailableTasksRes, c.Resources.Requests, c.Resources.Limits)
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions pkg/controllers/job/job_controller_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,23 @@ func applyPolicies(job *vkv1.Job, req *apis.Request) vkv1.Action {
return vkv1.SyncJobAction
}

func addResourceList(list, new v1.ResourceList) {
for name, quantity := range new {
func addResourceList(list, req, limit v1.ResourceList) {
for name, quantity := range req {
if value, ok := list[name]; !ok {
list[name] = *quantity.Copy()
} else {
value.Add(quantity)
list[name] = value
}
}

// If Requests is omitted for a container,
// it defaults to Limits if that is explicitly specified.
for name, quantity := range limit {
if _, ok := list[name]; !ok {
list[name] = *quantity.Copy()
}
}
}

//TaskPriority structure
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/job/job_controller_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ func TestAddResourceList(t *testing.T) {
}

for _, testcase := range testcases {
addResourceList(testcase.List, testcase.New)
addResourceList(testcase.List, testcase.New, nil)
}
}

Expand Down