Skip to content

Instantly share code, notes, and snippets.

@eparis
Last active March 8, 2016 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eparis/591788686969412309e4 to your computer and use it in GitHub Desktop.
Save eparis/591788686969412309e4 to your computer and use it in GitHub Desktop.
--- docs/api-reference/extensions/v1beta1/definitions.html 2016-03-08 16:20:38.877460369 -0500
+++ /tmp/07oF6j_definitions.html 2016-03-08 17:12:49.986244891 -0500
@@ -5728,7 +5728,7 @@ Both these may change in the future. Inc
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2016-03-08 21:20:37 UTC
+Last updated 2016-03-03 20:23:06 UTC
</div>
</div>
</body>
--- docs/api-reference/v1/definitions.html 2016-03-08 16:20:19.163729539 -0500
+++ /tmp/pXQ7Si_definitions.html 2016-03-08 17:12:50.100243338 -0500
@@ -7625,7 +7625,7 @@ The resulting set of endpoints can be vi
</div>
<div id="footer">
<div id="footer-text">
-Last updated 2016-03-08 21:20:17 UTC
+Last updated 2016-03-03 20:47:22 UTC
</div>
</div>
</body>
--- docs/man/man1/kubectl-patch.1 2016-03-08 16:19:16.175589575 -0500
+++ /tmp/XqyVyW_kubectl-patch.1 2016-03-08 17:12:54.655181289 -0500
@@ -20,7 +20,7 @@ JSON and YAML formats are accepted.
.PP
Please refer to the models in
-\[la]https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/api-reference/v1/definitions.html\[ra] to find if a field is mutable.
+\[la]https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html\[ra] to find if a field is mutable.
.SH OPTIONS
--- docs/man/man1/kubectl-replace.1 2016-03-08 16:19:16.213589056 -0500
+++ /tmp/FtE1vZ_kubectl-replace.1 2016-03-08 17:12:54.696180731 -0500
@@ -22,7 +22,7 @@ $ kubectl get TYPE NAME \-o yaml
.PP
Please refer to the models in
-\[la]https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/api-reference/v1/definitions.html\[ra] to find if a field is mutable.
+\[la]https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html\[ra] to find if a field is mutable.
.SH OPTIONS
--- pkg/kubectl/cmd/patch.go 2016-03-08 16:18:21.005342865 -0500
+++ /tmp/tjkJ2e_patch.go 2016-03-08 17:13:02.921068689 -0500
@@ -44,7 +44,7 @@ const (
JSON and YAML formats are accepted.
-Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/api-reference/v1/definitions.html to find if a field is mutable.`
+Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`
patch_example = `
# Partially update a node using strategic merge patch
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
--- pkg/kubectl/cmd/replace.go 2016-03-08 16:18:20.858344872 -0500
+++ /tmp/lLkxmi_replace.go 2016-03-08 17:13:02.961068144 -0500
@@ -44,7 +44,7 @@ JSON and YAML formats are accepted. If r
complete resource spec must be provided. This can be obtained by
$ kubectl get TYPE NAME -o yaml
-Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/release-1.2/docs/api-reference/v1/definitions.html to find if a field is mutable.`
+Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.`
replace_example = `# Replace a pod using the data in pod.json.
kubectl replace -f ./pod.json
--- pkg/version/base.go 2016-03-08 15:39:44.087102233 -0500
+++ /tmp/wLZvQd_base.go 2016-03-08 17:13:03.040067068 -0500
@@ -39,8 +39,8 @@ var (
// them irrelevant. (Next we'll take it out, which may muck with
// scripts consuming the kubectl version output - but most of
// these should be looking at gitVersion already anyways.)
- gitMajor string = "1" // major version, always numeric
- gitMinor string = "2+" // minor version, numeric possibly followed by "+"
+ gitMajor string = "" // major version, always numeric
+ gitMinor string = "" // minor version, numeric possibly followed by "+"
// semantic version, dervied by build scripts (see
// https://github.com/kubernetes/kubernetes/blob/master/docs/design/versioning.md
@@ -51,7 +51,7 @@ var (
// semantic version is a git hash, but the version itself is no
// longer the direct output of "git describe", but a slight
// translation to be semver compliant.
- gitVersion string = "v1.2.0-beta.0+$Format:%h$"
+ gitVersion string = "v0.0.0-master+$Format:%h$"
gitCommit string = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState string = "not a git tree" // state of git tree, either "clean" or "dirty"
)
--- plugin/pkg/scheduler/generic_scheduler.go 2016-03-08 15:39:44.088102219 -0500
+++ /tmp/odarpg_generic_scheduler.go 2016-03-08 17:13:03.066066714 -0500
@@ -20,6 +20,7 @@ import (
"bytes"
"fmt"
"math/rand"
+ "sort"
"strings"
"sync"
@@ -55,12 +56,13 @@ func (f *FitError) Error() string {
}
type genericScheduler struct {
- predicates map[string]algorithm.FitPredicate
- prioritizers []algorithm.PriorityConfig
- extenders []algorithm.SchedulerExtender
- pods algorithm.PodLister
- random *rand.Rand
- randomLock sync.Mutex
+ predicates map[string]algorithm.FitPredicate
+ prioritizers []algorithm.PriorityConfig
+ extenders []algorithm.SchedulerExtender
+ pods algorithm.PodLister
+ random *rand.Rand
+ randomLock sync.Mutex
+ lastNodeIndex uint64
}
// Schedule tries to schedule the given pod to one of node in the node list.
@@ -109,24 +111,16 @@ func (g *genericScheduler) selectHost(pr
return "", fmt.Errorf("empty priorityList")
}
+ sort.Sort(sort.Reverse(priorityList))
maxScore := priorityList[0].Score
- // idx contains indices of elements with score == maxScore.
- idx := []int{}
-
- for i, entry := range priorityList {
- if entry.Score > maxScore {
- maxScore = entry.Score
- idx = []int{i}
- } else if entry.Score == maxScore {
- idx = append(idx, i)
- }
- }
+ firstAfterMaxScore := sort.Search(len(priorityList), func(i int) bool { return priorityList[i].Score < maxScore })
g.randomLock.Lock()
- ix := g.random.Int() % len(idx)
+ ix := int(g.lastNodeIndex % uint64(firstAfterMaxScore))
+ g.lastNodeIndex++
g.randomLock.Unlock()
- return priorityList[idx[ix]].Host, nil
+ return priorityList[ix].Host, nil
}
// Filters the nodes to find the ones that fit based on the given predicate functions
@@ -188,7 +182,14 @@ func findNodesThatFit(pod *api.Pod, node
// Each priority function can also have its own weight
// The node scores returned by the priority function are multiplied by the weights to get weighted scores
// All scores are finally combined (added) to get the total weighted scores of all nodes
-func PrioritizeNodes(pod *api.Pod, nodeNameToInfo map[string]*schedulercache.NodeInfo, podLister algorithm.PodLister, priorityConfigs []algorithm.PriorityConfig, nodeLister algorithm.NodeLister, extenders []algorithm.SchedulerExtender) (schedulerapi.HostPriorityList, error) {
+func PrioritizeNodes(
+ pod *api.Pod,
+ nodeNameToInfo map[string]*schedulercache.NodeInfo,
+ podLister algorithm.PodLister,
+ priorityConfigs []algorithm.PriorityConfig,
+ nodeLister algorithm.NodeLister,
+ extenders []algorithm.SchedulerExtender,
+) (schedulerapi.HostPriorityList, error) {
result := schedulerapi.HostPriorityList{}
// If no priority configs are provided, then the EqualPriority function is applied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment