Skip to content

Scheduler cache does not remove node when remove label from node #5122

@Monkeytesting

Description

@Monkeytesting

Description

We use node-selector in volcano scheduler.

  containers:
  - args:
    - --node-selector=train:true

When the volcano-scheduler is running, we remove the label from **the node A **, but volcano still schedules the pod to the node A.

func (sc *SchedulerCache) SyncNode(nodeName string) error {
	node, err := sc.nodeInformer.Lister().Get(nodeName)
	if err != nil {
		if errors.IsNotFound(err) {
			deleteErr := sc.RemoveNode(nodeName)
			if deleteErr != nil {
				klog.Errorf("Failed to delete node <%s> and remove from cache: %s", nodeName, deleteErr.Error())
				return deleteErr
			}

			klog.V(3).Infof("Node <%s> was deleted, removed from cache.", nodeName)
			return nil
		}
		klog.Errorf("Failed to get node %s, error: %v", nodeName, err)
		return err
	}

	if !sc.nodeCanAddCache(node) {
		return nil
	}
	nodeCopy := node.DeepCopy()
	csiNode, err := sc.csiNodeInformer.Lister().Get(nodeName)
	if err == nil {
		sc.setCSIResourceOnNode(csiNode, nodeCopy)
	} else if !errors.IsNotFound(err) {
		return err
	}
	return sc.AddOrUpdateNode(nodeCopy)
}

Is the code missing removing node from cache in **if !sc.nodeCanAddCache(node) ** logic ?

Steps to reproduce the issue

Describe the results you received and expected

remove node when remove "the label" from node

What version of Volcano are you using?

master

Any other relevant information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions