wilfred-s commented on a change in pull request #101: [YUNIKORN-85] Improve
recovery performance by querying all pods once instead of querying pods on
specified node for many times
URL:
https://github.com/apache/incubator-yunikorn-k8shim/pull/101#discussion_r406296925
##########
File path: pkg/cache/context_recovery.go
##########
@@ -80,60 +80,67 @@ func (ctx *Context) recover(mgr []interfaces.Recoverable,
due time.Duration) err
// add all known nodes to cache, waiting for recover
for _, node := range allNodes {
ctx.nodes.addAndReportNode(node, false)
- // current, disable getting pods for a node during test,
- // because in the tests, we don't really send existing
allocations
- // we simply simulate to accept or reject nodes on conditions.
- if !ctx.apiProvider.IsTestingMode() {
- var podList *corev1.PodList
- podList, err =
ctx.apiProvider.GetAPIs().KubeClient.GetClientSet().
- CoreV1().Pods("").
- List(metav1.ListOptions{
- FieldSelector:
fmt.Sprintf("spec.nodeName=%s", node.Name),
- })
- if err != nil {
- return err
- }
+ }
- occupiedResources := common.NewResourceBuilder().Build()
- for _, pod := range podList.Items {
- // only handle assigned pods
- if !utils.IsAssignedPod(&pod) {
- continue
- }
- // yunikorn scheduled pods add to existing
allocations
- if utils.GeneralPodFilter(&pod) {
- if existingAlloc :=
getExistingAllocation(mgr, &pod); existingAlloc != nil {
- log.Logger.Debug("existing
allocation",
- zap.String("appID",
existingAlloc.ApplicationID),
- zap.String("podUID",
string(pod.UID)),
-
zap.String("podNodeName", existingAlloc.NodeID))
- if err =
ctx.nodes.addExistingAllocation(existingAlloc); err != nil {
- log.Logger.Warn("add
existing allocation failed", zap.Error(err))
- }
- }
- } else if utils.IsPodRunning(&pod) {
- // pod is running but not scheduled by
us
- // we should report this occupied
resource to scheduler-core
- occupiedResources =
common.Add(occupiedResources, common.GetPodResource(&pod))
- if err = ctx.nodes.cache.AddPod(&pod);
err != nil {
- log.Logger.Warn("failed to
update scheduler-cache",
- zap.Error(err))
+ // current, disable getting pods for a node during test,
+ // because in the tests, we don't really send existing allocations
+ // we simply simulate to accept or reject nodes on conditions.
+ if !ctx.apiProvider.IsTestingMode() {
+ var podList *corev1.PodList
+ podList, err =
ctx.apiProvider.GetAPIs().KubeClient.GetClientSet().
+ CoreV1().Pods("").
+ List(metav1.ListOptions{})
+ if err != nil {
+ return err
+ }
+
+ nodeOccupiedResources := make(map[string]*si.Resource)
+ //occupiedResources := common.NewResourceBuilder().Build()
Review comment:
nit: remove commented out code
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services