Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

update node info no matter what node info changed #859

Merged
merged 1 commit into from
May 30, 2019
Merged
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
12 changes: 1 addition & 11 deletions pkg/scheduler/cache/event_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package cache

import (
"fmt"
"reflect"

"github.com/golang/glog"

Expand Down Expand Up @@ -269,19 +268,10 @@ func (sc *SchedulerCache) addNode(node *v1.Node) error {
return nil
}

func isNodeInfoUpdated(oldNode, newNode *v1.Node) bool {
return !reflect.DeepEqual(oldNode.Status.Allocatable, newNode.Status.Allocatable) ||
!reflect.DeepEqual(oldNode.Spec.Taints, newNode.Spec.Taints) ||
!reflect.DeepEqual(oldNode.Labels, newNode.Labels) ||
!reflect.DeepEqual(oldNode.Spec.Unschedulable, newNode.Spec.Unschedulable)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it OK to add !reflect.DeepEqual(oldNode.Status.Conditions, newNode.Status.Conditions) here? There are a lot of NodeUpdate, and we do not need update it every time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check condition is better :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In default scheduler, no matter what node info changed, it always update the cache. There are not only node condition that we cared about when scheduling but also some other info, such as when we add ImageLocalityPriority, we need care about the change of node status Images info. I do not think it will have any benefits if we add more and more DeepEqual than we update the cache directly when node update.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm... let's get this merged firstly; if any performance issue, let's enhance it in another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hex108 , WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK with it.

}

// Assumes that lock is already acquired.
func (sc *SchedulerCache) updateNode(oldNode, newNode *v1.Node) error {
if sc.Nodes[newNode.Name] != nil {
if isNodeInfoUpdated(oldNode, newNode) {
sc.Nodes[newNode.Name].SetNode(newNode)
}
sc.Nodes[newNode.Name].SetNode(newNode)
return nil
}

Expand Down