This repository has been archived by the owner on May 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 264
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#642-#638-#645-#647-#651-#652-#655-#658-#649-#660-#666-#671-#673-upstream-release-0.4 Automated cherry pick of #643: Return err in Allocate if any error occurs #642: Add event when task is scheduled #638: Take init containers into account when getting pod resource #645: Order task by CreationTimestamp first, then by UID #647: In allocate, skip adding Job if its queue is not found #651: Return err in functions of session.go if any error occurs #652: Change run option SchedulePeriod's type to make it clear #655: Do graceful eviction using default policy #658: Address helm install error in tutorial.md #649: Preempt lowest priority task first #660: Fix sub exception in reclaim and preempt #666: Fix wrong caculation for deserved in proportion plugin #671: Change base image to alphine to reduce image size #673: Do not create PodGroup and Job for task whose scheduler is
- Loading branch information
Showing
20 changed files
with
460 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package options | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
"time" | ||
|
||
"github.com/spf13/pflag" | ||
) | ||
|
||
func TestAddFlags(t *testing.T) { | ||
fs := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError) | ||
s := NewServerOption() | ||
s.AddFlags(fs) | ||
|
||
args := []string{ | ||
"--schedule-period=5m", | ||
} | ||
fs.Parse(args) | ||
|
||
// This is a snapshot of expected options parsed by args. | ||
expected := &ServerOption{ | ||
SchedulerName: defaultSchedulerName, | ||
SchedulePeriod: 5 * time.Minute, | ||
DefaultQueue: defaultQueue, | ||
ListenAddress: defaultListenAddress, | ||
} | ||
|
||
if !reflect.DeepEqual(expected, s) { | ||
t.Errorf("Got different run options than expected.\nGot: %+v\nExpected: %+v\n", s, expected) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
From ubuntu:18.04 | ||
From alpine:3.9 | ||
|
||
ADD kube-batch /usr/local/bin | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
Copyright 2019 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package api | ||
|
||
import ( | ||
"k8s.io/api/core/v1" | ||
) | ||
|
||
// Refer k8s.io/kubernetes/pkg/scheduler/algorithm/predicates/predicates.go#GetResourceRequest. | ||
// | ||
// GetResourceRequest returns a *Resource that covers the largest width in each resource dimension. | ||
// Because init-containers run sequentially, we collect the max in each dimension iteratively. | ||
// In contrast, we sum the resource vectors for regular containers since they run simultaneously. | ||
// | ||
// To be consistent with kubernetes default scheduler, it is only used for predicates of actions(e.g. | ||
// allocate, backfill, preempt, reclaim), please use GetPodResourceWithoutInitContainers for other cases. | ||
// | ||
// Example: | ||
// | ||
// Pod: | ||
// InitContainers | ||
// IC1: | ||
// CPU: 2 | ||
// Memory: 1G | ||
// IC2: | ||
// CPU: 2 | ||
// Memory: 3G | ||
// Containers | ||
// C1: | ||
// CPU: 2 | ||
// Memory: 1G | ||
// C2: | ||
// CPU: 1 | ||
// Memory: 1G | ||
// | ||
// Result: CPU: 3, Memory: 3G | ||
func GetPodResourceRequest(pod *v1.Pod) *Resource { | ||
result := GetPodResourceWithoutInitContainers(pod) | ||
|
||
// take max_resource(sum_pod, any_init_container) | ||
for _, container := range pod.Spec.InitContainers { | ||
result.SetMaxResource(NewResource(container.Resources.Requests)) | ||
} | ||
|
||
return result | ||
} | ||
|
||
// GetPodResourceWithoutInitContainers returns Pod's resource request, it does not contain | ||
// init containers' resource request. | ||
func GetPodResourceWithoutInitContainers(pod *v1.Pod) *Resource { | ||
result := EmptyResource() | ||
for _, container := range pod.Spec.Containers { | ||
result.Add(NewResource(container.Resources.Requests)) | ||
} | ||
|
||
return result | ||
} |
Oops, something went wrong.