mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 05:40:42 +00:00 
			
		
		
		
	Add traces to scheduler
This commit is contained in:
		| @@ -441,7 +441,7 @@ type binder struct { | ||||
|  | ||||
| // Bind just does a POST binding RPC. | ||||
| func (b *binder) Bind(binding *api.Binding) error { | ||||
| 	glog.V(2).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name) | ||||
| 	glog.V(3).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name) | ||||
| 	ctx := api.WithNamespace(api.NewContext(), binding.Namespace) | ||||
| 	return b.Post().Namespace(api.NamespaceValue(ctx)).Resource("bindings").Body(binding).Do().Error() | ||||
| 	// TODO: use Pods interface for binding once clusters are upgraded | ||||
|   | ||||
| @@ -22,9 +22,11 @@ import ( | ||||
| 	"math/rand" | ||||
| 	"sort" | ||||
| 	"sync" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/golang/glog" | ||||
| 	"k8s.io/kubernetes/pkg/api" | ||||
| 	"k8s.io/kubernetes/pkg/util" | ||||
| 	"k8s.io/kubernetes/pkg/util/errors" | ||||
| 	"k8s.io/kubernetes/pkg/util/workqueue" | ||||
| 	"k8s.io/kubernetes/plugin/pkg/scheduler/algorithm" | ||||
| @@ -68,6 +70,14 @@ type genericScheduler struct { | ||||
| // If it succeeds, it will return the name of the node. | ||||
| // If it fails, it will return a Fiterror error with reasons. | ||||
| func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeLister) (string, error) { | ||||
| 	var trace *util.Trace | ||||
| 	if pod != nil { | ||||
| 		trace = util.NewTrace(fmt.Sprintf("Scheduling %s/%s", pod.Namespace, pod.Name)) | ||||
| 	} else { | ||||
| 		trace = util.NewTrace("Scheduling <nil> pod") | ||||
| 	} | ||||
| 	defer trace.LogIfLong(20 * time.Millisecond) | ||||
|  | ||||
| 	nodes, err := nodeLister.List() | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| @@ -82,8 +92,8 @@ func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeListe | ||||
| 		return "", err | ||||
| 	} | ||||
|  | ||||
| 	trace.Step("Computing predicates") | ||||
| 	filteredNodes, failedPredicateMap, err := findNodesThatFit(pod, nodeNameToInfo, g.predicates, nodes, g.extenders) | ||||
|  | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| @@ -95,11 +105,13 @@ func (g *genericScheduler) Schedule(pod *api.Pod, nodeLister algorithm.NodeListe | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	trace.Step("Prioritizing") | ||||
| 	priorityList, err := PrioritizeNodes(pod, nodeNameToInfo, g.prioritizers, algorithm.FakeNodeLister(filteredNodes), g.extenders) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
|  | ||||
| 	trace.Step("Selecting host") | ||||
| 	return g.selectHost(priorityList) | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user